Use ZK JSP Tags instead of ZK Filter
The ZK filter actually maps each HTML tag to the corresponding XHTML components. As described in the previous section, it consumes more memory than necessary since ZK has to maintain the states of all ZK components (including XUL and XHTML components).
Include ZUL pages in a JSP page
If some part of UI is made of HTML tags (such as header and banner), you could use JSP as the main page, implement the parts with dynamic content in ZUL, and then put them together with <jsp:include>. For example,
1 <%-- main.jsp --%>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 </head>
6 <body>
7 <%-- the static part such as header --%>
8 <div>any content you like</div>
9
10 <%-- include the dynamic part --%>
11 <jsp:include page="foo.zul"/>
12 ...
13 </body>
14 </head>
Use ZK components directly in a JSP page with ZK JSP tags
If you prefer to use ZK components directly in a JSP page, you could use ZK JSP tags. For example,
1 <%-- another.jsp --%>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z" %>
5
6 <html xmlns="http://www.w3.org/1999/xhtml">
7 <head>
8 <z:zkhead />
9 </head>
10 <body>
11 <%-- any JSP content --%>
12
13 <z:page>
14 <table>
15 <tr>
16 <td>Name</td>
17 <td><z:textbox/></td>
18 </tr>
19 </table>
20 </z:page>
21 </body>
22 </head>
where z:page
declares a ZK page and then ZK tags can be used inside it.
The above example is equivalent to the following code snippet, if a ZUL page is used,
1 <!-- another.zul -->
2 <?page complete="true"?>
3 <n:html xmlns="http://www.w3.org/1999/xhtml" xmlns:n="http://www.zkoss.org/2005/zk/native">
4 <n:head>
5 </n:head>
6 <n:body>
7 <!-- any HTML content -->
8
9 <n:table>
10 <n:tr>
11 <n:td>Name</n:td>
12 <n:td><textbox/></n:td>
13 </n:tr>
14 </n:table>
where <?page complete="true"?>
declares that this page is a complete page, i.e., it will provide HTML's html, head and body tags as shown above.