zk"

From Documentation
m (correct highlight (via JWB))
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
  <zk>...</zk>
 
  <zk>...</zk>
  
It is a special element used to aggregate other components. Unlike a real component (say, <tt>hbox</tt> or <tt>div</tt>), it is not part of the component tree being created. In other words, it doesn't represent any component. For example,
+
It is a special element used to aggregate other components. Unlike a real component (say, <code>hbox</code> or <code>div</code>), it is not part of the component tree being created. In other words, it doesn't represent any component. For example,
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 64: Line 64:
 
  [Optional][Default: ''ignored'']
 
  [Optional][Default: ''ignored'']
  
It specifies a collection of objects, such that the <tt>zk</tt> element will be evaluated repeatedly against each object in the collection. If not specified or empty, this attribute is ignored. If non-collection object is specified, it is evaluated only once as if a single-element collection is specified.
+
It specifies a collection of objects, such that the <code>zk</code> element will be evaluated repeatedly against each object in the collection. If not specified or empty, this attribute is ignored. If non-collection object is specified, it is evaluated only once as if a single-element collection is specified.
  
 
== forEachBegin ==
 
== forEachBegin ==
 
  [Optional][Default: 0]
 
  [Optional][Default: 0]
  
It is used with the <tt>forEach</tt> attribute to specify the starting offset when iterating a collection of objects. If not specified, it iterates from the first element, i.e., 0 is assumed.
+
It is used with the <code>forEach</code> attribute to specify the starting offset when iterating a collection of objects. If not specified, it iterates from the first element, i.e., 0 is assumed.
  
 
== forEachBegin ==
 
== forEachBegin ==
 
  [Optional][Default: 0]
 
  [Optional][Default: 0]
  
It is used with the <tt>forEach</tt> attribute to specify the index (starting from 0) that the iteration should begin at. If not specified, the iteration begins at the first element, i.e., 0 is assumed.
+
It is used with the <code>forEach</code> attribute to specify the index (starting from 0) that the iteration should begin at. If not specified, the iteration begins at the first element, i.e., 0 is assumed.
  
If <tt>forEachBegin</tt> is greater than or equals to the number of elements, no iteration is performed.
+
If <code>forEachBegin</code> is greater than or equals to the number of elements, no iteration is performed.
  
 
== forEachEnd ==
 
== forEachEnd ==
 
  [Optional][Default: ''the last element'']
 
  [Optional][Default: ''the last element'']
  
It is used with the <tt>forEach</tt> attribute to specify the index (starting from 0) the iteration should ends at (inclusive). If not specified, the iterations ends at the last element.
+
It is used with the <code>forEach</code> attribute to specify the index (starting from 0) the iteration should ends at (inclusive). If not specified, the iterations ends at the last element.
  
 
If forEachEnd is greater than or equals to the number of elements, the iteration ends at the last element.
 
If forEachEnd is greater than or equals to the number of elements, the iteration ends at the last element.
Line 91: Line 91:
  
 
<source lang="xml" >
 
<source lang="xml" >
  <zk swtich="${condition}"/>
+
  <zk switch="${condition}"/>
 
</source>
 
</source>
  
The only allowed children are the <tt>zk</tt> elements.
+
The only allowed children are the <code>zk</code> elements.
  
 
Fore more examples, please refer to [[ZK Developer's Reference/UI Composing/ZUML/Conditional Evaluation|ZK Developer's Reference: Conditional Evaluation]].
 
Fore more examples, please refer to [[ZK Developer's Reference/UI Composing/ZUML/Conditional Evaluation|ZK Developer's Reference: Conditional Evaluation]].
Line 107: Line 107:
 
</source>
 
</source>
  
If the value is a string starting and ending with slash, such as <tt>/a[p]*/</tt>, it is considered as a regular expression, which is used to match the switch condition.
+
If the value is a string starting and ending with slash, such as <code>/a[p]*/</code>, it is considered as a regular expression, which is used to match the switch condition.
 
<source lang="xml" >
 
<source lang="xml" >
 
  <zk case="/a[a-z]*/"/>
 
  <zk case="/a[a-z]*/"/>
Line 128: Line 128:
 
</source>
 
</source>
  
As shown, the value of the <tt>choose</tt> attribute is always empty, since it is used only to identify the range of mutually exclusive conditional evaluation.
+
As shown, the value of the <code>choose</code> attribute is always empty, since it is used only to identify the range of mutually exclusive conditional evaluation.
  
The only allowed children are the <tt>zk</tt> elements.
+
The only allowed children are the <code>zk</code> elements.
  
Fore more examples, please refer to [[ZK Developer's Reference/UI Composing/ZUML/Conditional Evaluation|ZK Developer's Reference: Conditional Evaluation]].
+
For more examples, please refer to [[ZK Developer's Reference/UI Composing/ZUML/Conditional Evaluation|ZK Developer's Reference: Conditional Evaluation]].
  
 
== when ==
 
== when ==
Line 145: Line 145:
 
It is evaluated if the condition matches.
 
It is evaluated if the condition matches.
  
Fore more examples, please refer to [[ZK Developer's Reference/UI Composing/ZUML/Conditional Evaluation|ZK Developer's Reference: Conditional Evaluation]].
+
For more examples, please refer to [[ZK Developer's Reference/UI Composing/ZUML/Conditional Evaluation|ZK Developer's Reference: Conditional Evaluation]].
  
 
==Version History==
 
==Version History==

Latest revision as of 13:27, 19 January 2022

Syntax:

<zk>...</zk>

It is a special element used to aggregate other components. Unlike a real component (say, hbox or div), it is not part of the component tree being created. In other words, it doesn't represent any component. For example,

 <window>
     <zk>
         <textbox/>
         <textbox/>
     </zk>
 </window>

is equivalent to

 <window>
     <textbox/>
     <textbox/>
 </window>

The main use is to represent multiple root elements in XML format.

 <?page title="Multiple Root"?>
 <zk>
     <window title="First">
     ...
     </window>
     <window title="Second" if="${param.secondRequired}">
     ...
     </window>
 </zk>

The other use is to iterate over versatile components.

 <window>
     <zk forEach="${mycols}">
         <textbox if="${each.useText}"/>
         <datebox if="${each.useDate}"/>
         <combobox if="${each.useCombo}"/>
     </zk>
 </window>

if

[Optional][Default: true]

Specifies the condition to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to false.

unless

[Optional][Default: false]

Specifies the condition not to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to true.

forEach

[Optional][Default: ignored]

It specifies a collection of objects, such that the zk element will be evaluated repeatedly against each object in the collection. If not specified or empty, this attribute is ignored. If non-collection object is specified, it is evaluated only once as if a single-element collection is specified.

forEachBegin

[Optional][Default: 0]

It is used with the forEach attribute to specify the starting offset when iterating a collection of objects. If not specified, it iterates from the first element, i.e., 0 is assumed.

forEachBegin

[Optional][Default: 0]

It is used with the forEach attribute to specify the index (starting from 0) that the iteration should begin at. If not specified, the iteration begins at the first element, i.e., 0 is assumed.

If forEachBegin is greater than or equals to the number of elements, no iteration is performed.

forEachEnd

[Optional][Default: the last element]

It is used with the forEach attribute to specify the index (starting from 0) the iteration should ends at (inclusive). If not specified, the iterations ends at the last element.

If forEachEnd is greater than or equals to the number of elements, the iteration ends at the last element.

switch

[Optional][Default: none]

Provide the context for mutually exclusive evaluation. The value specified in this attribute is called the switch condition.

 <zk switch="${condition}"/>

The only allowed children are the zk elements.

Fore more examples, please refer to ZK Developer's Reference: Conditional Evaluation.

case

[Optional][Default: none]

Provides an alternative within the switch evaluation.

 <zk case="apple"/>

If the value is a string starting and ending with slash, such as /a[p]*/, it is considered as a regular expression, which is used to match the switch condition.

 <zk case="/a[a-z]*/"/>

You can specify multiple cases by separating them with comma.

 <zk case="apple, ${special}"/>

Fore more examples, please refer to ZK Developer's Reference: Conditional Evaluation.

choose

[Optional][Default: none]

Provide the context for mutually exclusive evaluation.

 <zk choose="">

As shown, the value of the choose attribute is always empty, since it is used only to identify the range of mutually exclusive conditional evaluation.

The only allowed children are the zk elements.

For more examples, please refer to ZK Developer's Reference: Conditional Evaluation.

when

[Optional][Default: none]

Provides an alternative within the choose evaluation.

 <zk when="${fruit == 'apple'}">

It is evaluated if the condition matches.

For more examples, please refer to ZK Developer's Reference: Conditional Evaluation.

Version History

Version Date Content
     



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.