[UP] The UI language |
The element ui:ifvar This element compares a dialog variable with a value. If the result is true, the inner nodes are expanded and the condition code is set to true; otherwise the inner nodes are ignored, and the conditon code is set to false. The domain of comparisons that can be performed by ui:ifvar overlaps with ui:if. Especially the comparison of a non-associative variable with a value can be expressed by both elements. In doubt, use the shorter and more common ui:if. Declaration Level: Control structure <!ELEMENT ui:ifvar ANY> <!ATTLIST ui:ifvar variable NMTOKEN #REQUIRED index NMTOKEN #IMPLIED value CDATA #REQUIRED op CDATA "eq" > Attributes
Sub elements All page body elements may occur as sub elements. Operators The following operators are defined for ui:if (we call the value of the variable the "first operand", and the value denoted by the value attribute the "second operand"):
Since WDialog-2.1, it is possible to call any function defined for bracket expressions. The function is called with two arguments, and it is expected that the function returns a number indicating a boolean result: 0 is considered as the false value, and a non-zero number is considered as the true value. Currently, there aren't any other functions that would make sense to be called. The user may, however, define further functions. Regular expressions The engine matching regular expressions is PCRE (Perl-compatible regular expressions), so the Perl syntax is used. The expressions are not anchored by default, so have to write ^ and $$ to force anchoring. ^ matches the beginning of the string, and $$ matches the end of the string ("single-line expressions"). Note that you have to write double dollars $$ because the dollar character is the escape character for template parameters. Example <ui:dialog start-page="poll"> <ui:enumeration name="fruit"> <ui:enum internal="apple" external="I like apples"/> <ui:enum internal="orange" external="I like oranges"/> <ui:enum internal="bananas" external="I like bananas"/> <ui:enum internal="ananas" external="I like ananas"/> </ui:enumeration> <ui:variable name="pref" type="fruit"/> <ui:page name="poll"> ... Please click at your preferred fruit: <ui:select variable="pref" multiple="yes"/> ... </ui:page> <ui:page name="check"> ... <ui:ifvar variable="pref" value="0" op="card-eq"> You don't have selected any fruit sort. ... </ui:ifvar> ... </ui:page> </ui:dialog> Hints Note that template parameters and bracket expressions within ui:ifvar are unconditionally evaluated. See ui:cond for a discussion of the consequences of this fact. |