From Documentation

Jump to: navigation, search




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>




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