Include a Page
Apply (Recommended)
We suggest using
[
-
Doesn’t consume extra memory.
Because it’s a shadow element, it doesn’t create a corresponding component at the server side.
-
Doesn’t render an extra
<div>
surrounding its child components at the client-side.Include
renders a<div>
to enclose its child components. Sometimes the outer<div>
breaks the layout. -
Doesn’t create an ID space.
Include
itself is an ID space owner which affects you when locating a component with ZK selector syntax. -
It can render its child components upon parameters dynamically.
You can pass a parameter with data binding and bind to the parameter. When the parameter’s value changes, the content will change accordingly.
Include
Include allows you to include a zul page, an HTML, zhtml, JSP page, or a URL mapped to a servlet. For example,
<include src="another.zul"/>
<include src="another.jsp"/>
When including a ZUML page, the components specified in the ZUML page will become the child components of the org.zkoss.zul.Include component.
For example, suppose we have two ZUL pages as follows:
<!-- first.zul -->
<include src="second.zul"/>
and
<!-- second.zul -->
<listbox>
<listitem label="foo"/>
</listbox>
Then, listbox
in second.zul
will become the child of include
in
first.zul
.
When including a non-ZUML page (such as JSP), the output of the page will be the content of the org.zkoss.zul.Include component. Thus, the output must be a valid HTML fragment without `
, , `. If you prefer to create an independent page ([org.zkoss.zk.ui.Page](https://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/Page.html)), or want to include a page rendered by `Richlet` while the value of src ends with `.zul` or `.zhtml`, you could specify the mode with `defer` ([org.zkoss.zul.Include#setMode(java.lang.String)](https://www.zkoss.org/javadoc/latest/zk/org/zkoss/zul/Include.html#setMode(java.lang.String))). Then, `include` won't have any child. Rather, an instance of [org.zkoss.zk.ui.Page](https://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/Page.html) will be created to hold the content of `second.zul` or the content generated by Richlet. For more information, please refer to [ZK Component Reference: include](/zk_component_ref/include). # Classpath Web Resource Path ZK provides a special path URL starting with **`~./`**, it looks for a file under a folder starting with **`web`** in a web application's classpath, e.g. - `my-module.jar/web/`. - WEB-INF/classes/web So it will get a file under the path among all included jars. You can specify such URL in a component path-related attribute like: ```xml