<RULE> : Rule

Java class : leon.info.LyRule

ROLE

This element defines a rule that is automatically applied when an option is selected inside the graphical user interface. When the current option is deselected, the opposite rule is applied. When only single selection is permitted on this choice, rules defined over the deselected option are applied before those of the newly selected option.

ATTRIBUTES

<!ATTLIST RULE
	  id ID #IMPLIED
	  idref IDREF #REQUIRED
	  priority NMTOKEN #IMPLIED
	  operation ( SET_EDITABLE | SET_OPTIONAL | CLEAR | SET_VALUE) #REQUIRED
	  onCheck ( true | false) "true"
	  value CDATA #IMPLIED>
Attribute Mand. Description Default
id no This is the identifier of the rule.  
idref yes This is the identifier of the target field of this rule. The field will be modified according to the operation of this rule. Warning: the field should belong to the same class as the one of the choice field that contains this rule.  
priority no Integer defining the rule priority. A rule is triggered only if its priority is lower than the one of the application. The application priority is defined programmatically defined by the getPriorityLevel method of the leon.app.behavior.LyApplicationBehavior class associated with the application. The default priority level is 0.  
operation yes Defines the operation applied over the target field when this option is selected:
- SET_ENABLED: The field is enabled and the user may select values. The opposite rule sets the target field disable and the value its contains is discarded at validation of the form.
- SET_EDITABLE: The user may select values inside the field. The opposite rule prevents the user from selecting values inside the field, but the values it contains are taken into account at validation of the form.
- SET_OPTIONAL: The field becomes optional. The user may ignore this field and validate the form without selecting a value. The opposite rule writes the label of the field in bold and controls that the user has selected a value.
- CLEAR: The field is cleared; the selected values are erased (no opposite rule).
- RESET: The field takes the value it had at the starting of the action that displays the form. If such a value was null, the field is cleared (no opposite rule).
- SHOW: Shows the target field to the user, i.e. display the tab that contains the field (no opposite rule).
- SET_VISIBLE: Show/Hide the input field for the target field.
- SET_VALUE: Sets the target field to the value given by the 'value' attribute (no opposite rule).
- SET_LABEL: Sets the target field to the label given by the LABEL element (no opposite rule).
 
onCheck no This attribute specifies if the rule is triggered when the option is checked or unchecked. true
value no Value set on the field specified by the rule when the operation is SET_VALUE.  

ELEMENTS

<!ELEMENT RULE 
	  ((FILTER | FILTER_REF)?,
	   FORMULA?)>
Element Mand. Mult. Description
FILTER yes no Filter used to control when the rule is triggered when associated to a class.
FILTER_REF yes no Reference of the filter used to control when the rule is triggered when associated to a class.
FORMULA no no Formula used to set value when the operation is SET_VALUE.

SAMPLE

<CHOICE id="br_ori" multiple='true'>
	<F_BIND value="ORIGINE"/>
	<NAME value="BR_ORIGINE"/>
	<TAB value="TAB_EMISSION"/>
	<F_MARKS sort='true' filter='true' table='true'>
		<MARK name='EMISSION'/>
	</F_MARKS>
	<OPTIONS>
		<OPTION id="br_ori.0" name="fax" value="0" default='true'>
			<RULE id="r1" idref="br_fax" operation='SET_ENABLED'/>
		</OPTION>
		<OPTION id="br_ori.1" name="mail" value="1">
			<RULE id="r2" idref="br_mail" operation='SET_ENABLED'/>
		</OPTION>
		<OPTION id="br_ori.2" name="phone" value="2">
			<RULE id="r3" idref="br_phone" operation='SET_ENABLED'/>
		</OPTION>
		<OPTION id="br_ori.3" name="web" value="3">
			<RULE id="r4" idref="br_web" operation='SET_ENABLED'/>
		</OPTION>
	</OPTIONS>
</CHOICE>