CreateEvent"
From Documentation
Tmillsclare (talk | contribs) |
|||
Line 15: | Line 15: | ||
N/A | N/A | ||
+ | = Notes = | ||
+ | |||
+ | == Don't use with data binding == | ||
+ | |||
+ | When the data binder processed a collection of data in, say, a grid or a listbox, it will detach the original one, and then clone it to represent each item of the data. For example, | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <listbox model="@{person.interests}"> | ||
+ | <listitem self="@{each=obj}" value="@{obj}" onCreate="foo()"/> | ||
+ | </listbox> | ||
+ | </source> | ||
+ | |||
+ | where the execution sequence is as follows. | ||
+ | |||
+ | # ZK Loader creates a listbox and a listitem, and posts <tt>onCreate</tt> to the listitem (since it has a listener). | ||
+ | # The data binder processes all annotations, after all components are created. | ||
+ | ## When handling <tt>each</tt>, the data binder detaches the listitem, invokes <javadoc method="clone()">org.zkoss.zk.ui.Component</javadoc> to make a clone for each item (person.interests), and attach the clone to the listbox | ||
+ | # The listitem created by ZK Loader receives <tt>onCreate</tt>. Thus, whatever change the listener made won't affect the listitems attached the listbox. | ||
+ | |||
+ | In summary, when using data binding, don't use <code>onCreate</code>. | ||
=Supported events= | =Supported events= |
Revision as of 08:25, 7 July 2010
CreateEvent
- Demonstration: N/A
- Java API: CreateEvent
- JavaScript API: N/A
Employment/Purpose
Used to notify a window that all its children are created and initialized. UiEngine post this event to components that declares the onCreate handler (either as a method or as in instance definition).
Example
N/A
Notes
Don't use with data binding
When the data binder processed a collection of data in, say, a grid or a listbox, it will detach the original one, and then clone it to represent each item of the data. For example,
<listbox model="@{person.interests}">
<listitem self="@{each=obj}" value="@{obj}" onCreate="foo()"/>
</listbox>
where the execution sequence is as follows.
- ZK Loader creates a listbox and a listitem, and posts onCreate to the listitem (since it has a listener).
- The data binder processes all annotations, after all components are created.
- When handling each, the data binder detaches the listitem, invokes Component.clone() to make a clone for each item (person.interests), and attach the clone to the listbox
- The listitem created by ZK Loader receives onCreate. Thus, whatever change the listener made won't affect the listitems attached the listbox.
In summary, when using data binding, don't use onCreate
.
Supported events
None | None |
Supported Children
*NONE
Use cases
Version | Description | Example Location |
---|---|---|
Version History
Version | Date | Content |
---|---|---|