On-demand Evaluation"

From Documentation
m
Line 5: Line 5:
 
For example, you could split a ZUML document into multiple, and then load the required ones when necessary. Please refer to the [[ZK Developer's Reference/UI Composing/ZUML/Load ZUML in Java|Load ZUML in Java]] section for how to load a ZUML document dynamically.
 
For example, you could split a ZUML document into multiple, and then load the required ones when necessary. Please refer to the [[ZK Developer's Reference/UI Composing/ZUML/Load ZUML in Java|Load ZUML in Java]] section for how to load a ZUML document dynamically.
  
It improves the performance in both the server and client sides. It is suggested to apply this technique when appropriate. ZK Loader provides a standard on-demand evaluation called ''fulfill'' to simplify the implementation.
+
It improves the performance in both the server and client sides. It is suggested to apply this technique when appropriate. In additions, ZK Loader provides a standard on-demand evaluation called ''fulfill'' to simplify the implementation as described in the following section.
  
 
=Load-on-Demand with the fulfill attribute=
 
=Load-on-Demand with the fulfill attribute=
 +
 +
The simplest way to defer the creation of the child components is to use the fulfill attribute. For example, the comboitem component in the following code snippet will not be created, until the combobox component receives the onOpen event, indicating comboitem is becoming visible.
 +
 +
<source lang="xml">
 +
<combobox fulfill="onOpen">
 +
    <comboitem label="First Option"/>   
 +
</combobox>
 +
</source>
 +
 +
In other words, if a ZUML element is specified with the fulfill attribute, its child elements won't be processed until the event specified as the value of the fulfill attribute is received.
 +
 +
If the event to trigger the creation of children is targeted to another component, you can specify the target component's identifier after colon as depicted below.
 +
 +
<source lang="xml">
 +
<button id="btn" label="show" onClick="content.visible = true"/>
 +
<div id="content" fulfill="btn.onClick">
 +
    Any content created automatically when btn is clicked   
 +
</div>
 +
</source>
 +
 +
If the components belong to different ID space, you can specify a path after the event name as follows.
 +
 +
<source lang="xml">
 +
<button id="btn" label="show" onClick="content.visible = true"/>
 +
<window id="content" fulfill="../btn.onClick">
 +
    Any content created automatically when btn is clicked   
 +
</window>
  
 
=Version History=
 
=Version History=

Revision as of 10:37, 7 December 2010


On-demand Evaluation


By default, ZK creates components based on what are defined in a ZUML document, when loading the document. However, we can defer the creation of some sections of components, until necessary, such as becoming visible. This technique is called load-on-demand or render-on-demand.

For example, you could split a ZUML document into multiple, and then load the required ones when necessary. Please refer to the Load ZUML in Java section for how to load a ZUML document dynamically.

It improves the performance in both the server and client sides. It is suggested to apply this technique when appropriate. In additions, ZK Loader provides a standard on-demand evaluation called fulfill to simplify the implementation as described in the following section.

Load-on-Demand with the fulfill attribute

The simplest way to defer the creation of the child components is to use the fulfill attribute. For example, the comboitem component in the following code snippet will not be created, until the combobox component receives the onOpen event, indicating comboitem is becoming visible.

<combobox fulfill="onOpen">
    <comboitem label="First Option"/>    
</combobox>

In other words, if a ZUML element is specified with the fulfill attribute, its child elements won't be processed until the event specified as the value of the fulfill attribute is received.

If the event to trigger the creation of children is targeted to another component, you can specify the target component's identifier after colon as depicted below.

<button id="btn" label="show" onClick="content.visible = true"/>
<div id="content" fulfill="btn.onClick">
    Any content created automatically when btn is clicked    
</div>

If the components belong to different ID space, you can specify a path after the event name as follows.

<source lang="xml"> <button id="btn" label="show" onClick="content.visible = true"/> <window id="content" fulfill="../btn.onClick">

   Any content created automatically when btn is clicked    

</window>

Version History

Last Update : 2010/12/07


Version Date Content
     



Last Update : 2010/12/07

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