zk"

From Documentation
m
m
Line 3: Line 3:
 
__TOC__
 
__TOC__
  
<source lang="xml" >
+
'''Syntax:'''
 
  <zk>...</zk>
 
  <zk>...</zk>
</source>
 
  
 
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, <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,
Line 53: Line 52:
  
 
== if ==
 
== if ==
<source lang="bash" >
+
[Optional][Default: true]
[Optional][Default: true]
 
</source>
 
  
 
Specifies the condition to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to false.
 
Specifies the condition to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to false.
  
 
== unless ==
 
== unless ==
 
+
[Optional][Default: false]
<source lang="bash" >
 
[Optional][Default: false]
 
</source>
 
  
 
Specifies the condition ''not'' to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to true.
 
Specifies the condition ''not'' to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to true.
  
 
== forEach ==
 
== forEach ==
<source lang="bash" >
+
[Optional][Default: ''ignored'']
[Optional][Default: ''ignored'']
 
</source>
 
  
 
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 <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.
  
 
== forEachBegin ==
 
== forEachBegin ==
 
+
[Optional][Default: 0]
<source lang="xml" >
 
[Optional][Default: 0]
 
</source>
 
  
 
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 <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.
  
 
== forEachBegin ==
 
== forEachBegin ==
 
+
[Optional][Default: 0]
<source lang="xml" >
 
[Optional][Default: 0]
 
</source>
 
  
 
It is used with the <tt>forEach</tt> attribute to specify the index (starting from 0) that the iteration shall begin at. If not specified, the iteration begins at the first element, i.e., 0 is assumed.
 
It is used with the <tt>forEach</tt> attribute to specify the index (starting from 0) that the iteration shall begin at. If not specified, the iteration begins at the first element, i.e., 0 is assumed.
Line 93: Line 79:
  
 
== forEachEnd ==
 
== forEachEnd ==
 
+
[Optional][Default: ''the last element'']
<source lang="xml" >
 
[Optional][Default: ''the last element'']
 
</source>
 
  
 
It is used with the <tt>forEach</tt> attribute to specify the index (starting from 0) the iteration shall ends at (inclusive). If not specified, the iterations ends at the last element.
 
It is used with the <tt>forEach</tt> attribute to specify the index (starting from 0) the iteration shall ends at (inclusive). If not specified, the iterations ends at the last element.
Line 103: Line 86:
  
 
== switch ==
 
== switch ==
<source lang="xml" >
+
[Optional][Default: ''none'']
[Optional][Default: ''none'']
 
</source>
 
  
 
Provide the context for mutually exclusive evaluation. The value specified in this attribute is called the switch condition.
 
Provide the context for mutually exclusive evaluation. The value specified in this attribute is called the switch condition.
Line 116: Line 97:
  
 
== case ==
 
== case ==
 
+
[Optional][Default: ''none'']
<source lang="bash" >
 
[Optional][Default: ''none'']
 
</source>
 
  
 
Provides an alternative within the switch evaluation.
 
Provides an alternative within the switch evaluation.
Line 138: Line 116:
  
 
== choose ==
 
== choose ==
 
+
[Optional][Default: ''none'']
<source lang="bash" >
 
[Optional][Default: ''none'']
 
</source>
 
  
 
Provide the context for mutually exclusive evaluation.
 
Provide the context for mutually exclusive evaluation.
Line 152: Line 127:
  
 
== when ==
 
== when ==
 
+
[Optional][Default: ''none'']
<source lang="bash" >
 
[Optional][Default: ''none'']
 
</source>
 
  
 
Provides an alternative within the choose evaluation.
 
Provides an alternative within the choose evaluation.

Revision as of 10:33, 18 November 2010

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 shall 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 shall 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 swtich="${condition}"/>

The only allowed children are the zk elements.

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}"/>

choose

[Optional][Default: none]

Provide the context for mutually exclusive evaluation.

 <zk choose="">

The only allowed children are the zk elements.

when

[Optional][Default: none]

Provides an alternative within the choose evaluation.

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

It is evaluated if the condition matches.

Version History

Version Date Content
     



Last Update : 2010/11/18

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