Enrich a Dynamically Generated Page with ZK Filter

From Documentation
Revision as of 08:16, 19 July 2010 by Char (talk | contribs) (Created page with '{{ZKDevelopersGuidePageHeader}} If you prefer to ''ajax''-ize a dynamically generated HTML page (e.g., the output of a Velocity Servlet), you could use the ZK Filter to process …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Enrich a Dynamically Generated Page with ZK Filter


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


If you prefer to ajax-ize a dynamically generated HTML page (e.g., the output of a Velocity Servlet), you could use the ZK Filter to process the generated page. To enable the ZK filter, you have to configure web.xml, as shown below.

<filter>
    <filter-name>zkFilter</filter-name>
    <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class>
    <init-param>
        <param-name>extension</param-name>
        <param-value>html</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>zkFilter</filter-name>
    <url-pattern>/my/dyna.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>zkFilter</filter-name>
    <url-pattern>/my/dyna/*</url-pattern>
</filter-mapping>

where url-pattern is application dependent. The extension parameter (init-param) defines the language of the dynamical output. By default, it is html. If it is xul/html, specify zul as the extension.

Tip: In most cases, ZK JSP tags are easier to use and consume less memory than the ZK filter. Refer to the Performance Tips section in the Advance Features chapter.

Notice that, if you want to filter the output from include and/or forward, remember to specify the dispatcher element with REQUEST and/or INCLUDE. Consult the Java Servlet Specification for details. For example,

<filter-mapping>
    <filter-name>zkFilter</filter-name>
    <url-pattern>/my/dyna/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>



Last Update : 2010/07/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.