Include

The include component is used to include the output generated by another servlet. The servlet could be anything including JSF, JSP and even another ZUML page.

<window title="include demo" border="normal" width="300px">
    Hello, World!    
    <include src="/userguide/misc/includedHello.zul"/>    
    <include src="/html/frag.html?some=any"/>    
    <include src="mypage" argument="${anyValue}" other="${anotherValue}"/>    
</window>

Like all other properties, you could dynamically change the src attribute to include the output from a different servlet at the run time.

If the included output is another ZUML, developers are allowed to access components in the included page as if they are part of the containing page.

If the include component is used to include a ZUML page, the included page will become part of the desktop. However, the included page is not visible until the request is processed completely. In other words, it is visible only in the following events, triggered by user or timer.

The reason is that the include component includes a page as late as the Rendering phase. On the other hand, zscript takes place at the Component Creation phase, and onCreate takes place at the Event Processing Phase. They both execute before the inclusion.

Pass Values to the Included Page

There are two ways to pass values to the included page. First, you can pass them with the query string.

<include src="mypage?some=something"/>

Then, in the included page, you can access them with the getParameter method of the Execution interface or the ServletRequest interface. In EL expressions (of the included page), you can use the param variable to access them. However, you can only pass String-typed values with the query string.

${param.some}

Alternatively, we can pass any kind of values with the so-called dynamic properties by use of the setDynamicProperty method or, in ZUL, a dynamic property as follows:

<include src="mypage" some="something" another="${expr}"/>

With the dynamic properties, you can pass non-String-typed values. In the included page, you can access them with the getAttribute method of the Execution interface or the ServletRequest interface. In EL expressions (of the included page), you can use the requestScope variable to access them.

${requestScope.some}

Class Name

org.zkoss.zul.Include

Supported Child Components

*NONE

Supported Events

*NONE

Properties

Property

Description

Data Type

Default Value

src

Sets whether user can open or close the group box.

boo lean

true

localized

Sets the CSS style for the content block of the groupbox.

java.lang.Str ing

<null>

ope n

Opens or closes this groupbox.

boo lean

true

Methods

Name

Description

Data Type

Values

IsChildable

Determines whether it accepts child components

Note: No child is allowed.

Boolean

false

Inherited From