In this phase, ZK loader interprets an ZUML page. It creates and initializes components accordingly. It takes several steps as follows.
For each element, it examines the if and unless attribute to decide whether it is effective. If not, the element and all of its child elements are ignored.
If the forEach attribute is specified with a collection of items, ZK repeats the following steps for each item in the collection.
Creates a component based on the element name, or by use of the class specified in the use attribute, if any.
Initializes the members one-by-one based on the order that attributes are specified in the ZUML page.
Interprets the nested elements and repeat the whole procedure.
Invokes the afterCompose method if the component implements the org.zkoss.zk.ui.ext.AfterCompose interface[29].
After all children are created, the onCreate event is sent to this component, such that application could initialize the content of some elements later. Notice that the onCreate events are posted for child components first.
Note: an developer can perform some application-specific initialization by listening to the onCreate event or implementing AfterCompose. AfterCompose is called in the Component Creation Phase, while the onCreate event is handled by an event listener.
An event listener is free to suspend and resume the execution (such as creating modal dialogs), while AfterCompose is a bit faster since no need to fork another thread.