Page Initialization"

From Documentation
m
Line 1: Line 1:
 
{{ZKDevelopersReferencePageHeader}}
 
{{ZKDevelopersReferencePageHeader}}
  
Sometimes it is helpful to run some code before ZK Loader instantiates any component. For example, check if the user ha the authority to access, initialize some data, or prepare some variables for EL expressions<ref>The preparation of variables for EL expression is generally better to be done in the constructor of <javadoc type="interface">org.zkoss.xel.VariableResolver</javadoc> (and specified with [[ZUML Reference/ZUML/Processing Instructions/variable-resolver|the variable-resolver directive]].</ref>.
+
Sometimes it is helpful to run some code before ZK Loader instantiates any component. For example, check if the user ha the authority to access, initialize some data, or prepare some variables for EL expressions.
  
 
This can be done easily by implementing <javadoc type="interface">org.zkoss.zk.ui.util.Initiator</javadoc>, and then specifying it with [[ZUML Reference/ZUML/Processing Instructions/init|the init directive]].
 
This can be done easily by implementing <javadoc type="interface">org.zkoss.zk.ui.util.Initiator</javadoc>, and then specifying it with [[ZUML Reference/ZUML/Processing Instructions/init|the init directive]].
Line 16: Line 16:
  
 
The data binder will parse all annotations and bind the data according to the annotations, after all components in a ZUML document is instantiated.
 
The data binder will parse all annotations and bind the data according to the annotations, after all components in a ZUML document is instantiated.
 +
 +
=Initiator and EL=
 +
To prepare a variable for EL expression in an initiator<ref>The preparation of variables for EL expression is generally better to be done in the constructor of <javadoc type="interface">org.zkoss.xel.VariableResolver</javadoc> (and specified with [[ZUML Reference/ZUML/Processing Instructions/variable-resolver|the variable-resolver directive]].</ref>
  
 
<blockquote>
 
<blockquote>

Revision as of 07:28, 26 November 2010


Page Initialization


Sometimes it is helpful to run some code before ZK Loader instantiates any component. For example, check if the user ha the authority to access, initialize some data, or prepare some variables for EL expressions.

This can be done easily by implementing Initiator, and then specifying it with the init directive.

<?init class="com.foo.MyInitial"?>

A typical use of the init directive is to specify a data binder, as shown below.

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>

The data binder will parse all annotations and bind the data according to the annotations, after all components in a ZUML document is instantiated.

Initiator and EL

To prepare a variable for EL expression in an initiator[1]


  1. The preparation of variables for EL expression is generally better to be done in the constructor of VariableResolver (and specified with the variable-resolver directive.

Version History

Last Update : 2010/11/26


Version Date Content
     



Last Update : 2010/11/26

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