Enrich a Dynamically Generated Page with ZK Filter"

From Documentation
(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 …')
 
m (correct highlight (via JWB))
 
Line 1: Line 1:
 
{{ZKDevelopersGuidePageHeader}}
 
{{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 the generated page. To enable the ZK filter, you have to configure <tt>web.xml</tt>, as shown below.
+
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 <code>web.xml</code>, as shown below.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 22: Line 22:
 
</source>
 
</source>
  
where <tt>url-pattern</tt> is application dependent. The <tt>extension</tt> parameter (<tt>init-param</tt>) defines the language of the dynamical output. By default, it is <tt>html</tt>. If it is <tt>xul/html</tt>, specify <tt>zul</tt> as the extension.
+
where <code>url-pattern</code> is application dependent. The <code>extension</code> parameter (<code>init-param</code>) defines the language of the dynamical output. By default, it is <code>html</code>. If it is <code>xul/html</code>, specify <code>zul</code> 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.
 
'''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.

Latest revision as of 10:39, 19 January 2022

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 : 2022/01/19

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