Home   Single Page

The fulfill Attribute

fulfill="event-expr"fulfill="event-expr1, event-expr2, event-expr3"fulfill="event-expr=uri-expr"fulfill="event-expr1, event-expr2=uri-expr2"fulfill="=uri_expr"

where event-expr, event-expr1 and others are called event expressions. An event expression is used to identify an event that is targeting a particular component. It can be one of the following formats:

event-nametarget-id.event-nameid1/id2/id3.event-name${el-expr}.event-name

and uri-expr is an URI or an EL expression returning URI. For example,

/my/super.zul${my_super_zul}

It is used to specify when to create the child components. By default (i.e., fulfill is not specified), the child components are created right after its parent component, when the ZUML page is loaded.

If you want to defer the creation of the child components, you can specify the condition with the fulfill attribute. The condition consists of the event name and, optionally, the target component's identifier or path. It means that the child elements won't be processed, until the event is received by, if specified, the target component. If the identifier is omitted, the same component is assumed.

If an EL expression is specified, it must return a component, an identifier or a path.

Refer to the Load on Demand section for more details.

With an URI Expression

If the URI expression is specified, ZK loader will create the components defined in the specified URI and assign them as the child components. To create the components defied in the specified URI, ZK actually invokes the createComponents method defined in Executions. For example, ZK loader, in the following example, will invoke Executions.createComponents("/my/super.zul", d, null) to create child components for the d div, when the b button is clicked.

<button id="b" label="open"/>
<div id="d" fulfill="b.onClick=/my/super.zul">
</div>

If the event expression is not specified, ZK loader creates the components immediately - after all properties are assigned and child components are created. In the following example, ZK loader creates combobox first and then create components defined in /my/super.zul.

<div fulfill="=/my/super.zul">
    <combobox/>    
</div>

The onFulfill Event

After ZK applies the fulfill condition, i.e., creates all descendant components, it fires the onFulfill event with an instance of org.zkoss.zk.ui.event.FulfillEvent to notify the component for further processing if any.

For example, if you use the wireVariables method of the org.zkoss.zk.ui.Components class, you might have to call wireVariables again to wire the new components in the onFulfill event.

<div fulfill="b1.onClick, b2.onOpen"
onFulfill="Components.wireVariables(self, controller)">

...

</div>