apply"

From Documentation
(Created page with '== The apply Attribute == apply="a-class-name" apply="class1, class2,..." apply="${EL_returns_a_class_or_a_collection_of_classes}" apply="${EL_returns_an_instance_or_a_collec…')
 
Line 5: Line 5:
 
  apply="${EL_returns_an_instance_or_a_collection_of_Composer_instances}"
 
  apply="${EL_returns_an_instance_or_a_collection_of_Composer_instances}"
  
It specifies a class, a collection of classes that are used to initialize the component. The class must implement the <tt>org.zkoss.zk.util.Composer</tt> interface. And then, you can do the initialization in the <tt>doAfterCompose</tt> method, since it is called after the component and all its children are instantiated.
+
It specifies a class, a collection of classes that are used to initialize the component. The class must implement the <javadoc>org.zkoss.zk.util.Composer</javadoc> interface. And then, you can do the initialization in the <tt>doAfterCompose</tt> method, since it is called after the component and all its children are instantiated.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 15: Line 15:
 
'''Note:''' the EL expressions are, if specified, evaluated before the component is instantiated. So you cannot reference to the component. Moreover, the <tt>self</tt> variable references to the parent component, if any, or the current page, if it is the root component, in the EL expressions specified in this attribute.
 
'''Note:''' the EL expressions are, if specified, evaluated before the component is instantiated. So you cannot reference to the component. Moreover, the <tt>self</tt> variable references to the parent component, if any, or the current page, if it is the root component, in the EL expressions specified in this attribute.
  
If you want more control such as handling the exception, you can also implement the <tt>org.zkoss.zk.util.ComposerExt</tt> interface.
+
If you want more control such as handling the exception, you can also implement the <javadoc>org.zkoss.zk.util.ComposerExt</javadoc> interface.

Revision as of 04:41, 8 July 2010

The apply Attribute

apply="a-class-name"
apply="class1, class2,..."
apply="${EL_returns_a_class_or_a_collection_of_classes}"
apply="${EL_returns_an_instance_or_a_collection_of_Composer_instances}"

It specifies a class, a collection of classes that are used to initialize the component. The class must implement the Composer interface. And then, you can do the initialization in the doAfterCompose method, since it is called after the component and all its children are instantiated.

 <window apply="MyComposer"/>

In addition, you specify a Composer instance, or a collection of Composer instances by use of EL expressions.

Note: the EL expressions are, if specified, evaluated before the component is instantiated. So you cannot reference to the component. Moreover, the self variable references to the parent component, if any, or the current page, if it is the root component, in the EL expressions specified in this attribute.

If you want more control such as handling the exception, you can also implement the ComposerExt interface.