The richlet-mapping Element"
m (correct highlight (via JWB)) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{ZKConfigurationReferencePageHeader}} | {{ZKConfigurationReferencePageHeader}} | ||
− | Once [[ZK Configuration Reference/zk.xml/The richlet Element|a richlet is declared]], you could map it to any number of URL by using < | + | Once [[ZK Configuration Reference/zk.xml/The richlet Element|a richlet is declared]], you could map it to any number of URL by using <code>richlet-mapping</code> as depicted below. |
<source lang="xml" > | <source lang="xml" > | ||
Line 14: | Line 14: | ||
</source> | </source> | ||
− | When mapping, you should consider the < | + | When mapping, you should consider the <code>servlet-mapping</code> of [[ZK Configuration Reference/web.xml/ZK Loader|ZK Loader]] in [[ZK Configuration Reference/web.xml|web.xml]], for example, if you want the Richlet work with <code>/path/*</code>, you may specify the servlet-mapping in web.xml as follows: |
<source lang="xml" > | <source lang="xml" > | ||
Line 33: | Line 33: | ||
In this case, both Richlet and ZUL will work great. If you swap the url-pattern of servlet-mapping with richlet-mapping, only the Richlet will work well. | In this case, both Richlet and ZUL will work great. If you swap the url-pattern of servlet-mapping with richlet-mapping, only the Richlet will work well. | ||
+ | |||
+ | '''Note:''' Since ZK 7.0.0 release, when use ZK Richlet Filter, the url-pattern of the richlet-mapping should start with the prefix url-pattern in filter-mapping. For example, | ||
+ | |||
+ | In web.xml | ||
+ | <source lang="xml" highlight="3,8"> | ||
+ | <filter> | ||
+ | <filter-name>RichletFilter</filter-name> | ||
+ | <filter-class>org.zkoss.zk.ui.http.RichletFilter</filter-class> | ||
+ | </filter> | ||
+ | |||
+ | <filter-mapping> | ||
+ | <filter-name>RichletFilter</filter-name> | ||
+ | <url-pattern>/zk/*</url-pattern> | ||
+ | </filter-mapping> | ||
+ | </source> | ||
+ | |||
+ | In zk.xml | ||
+ | <source lang="xml" highlight="3"> | ||
+ | <richlet-mapping> | ||
+ | <richlet-name>Test</richlet-name> | ||
+ | <url-pattern>/zk/foo/*</url-pattern> | ||
+ | </richlet-mapping> | ||
+ | </source> | ||
− | The URL specified in the < | + | The URL specified in the <code>url-pattern</code> element must start with <code>/</code>. If the URI ends with <code>/*</code>, then it is matched to all request with the same prefix. To retrieve the real request, you can check the value returned by <javadoc type="interface" method="getRequestPath()">org.zkoss.zk.ui.Page</javadoc> of the current page. |
<source lang="java" > | <source lang="java" > | ||
Line 50: | Line 73: | ||
! Version !! Date !! Content | ! Version !! Date !! Content | ||
|- | |- | ||
− | | | + | | ZK 7.0.0 |
− | | | + | | August 2013 |
− | | | + | | [http://tracker.zkoss.org/browse/ZK-1882 Support Richlet with Servlet Filter] |
|} | |} | ||
{{ZKConfigurationReferencePageFooter}} | {{ZKConfigurationReferencePageFooter}} |
Latest revision as of 10:33, 19 January 2022
Once a richlet is declared, you could map it to any number of URL by using richlet-mapping
as depicted below.
<richlet-mapping>
<richlet-name>Test</richlet-name>
<url-pattern>/test</url-pattern>
</richlet-mapping>
<richlet-mapping>
<richlet-name>Test</richlet-name>
<url-pattern>/some/more/*</url-pattern>
</richlet-mapping>
When mapping, you should consider the servlet-mapping
of ZK Loader in web.xml, for example, if you want the Richlet work with /path/*
, you may specify the servlet-mapping in web.xml as follows:
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>/path/*</url-pattern>
</servlet-mapping>
and specify the richlet-mapping as follows:
<richlet-mapping>
<richlet-name>Test</richlet-name>
<url-pattern>/*</url-pattern>
</richlet-mapping>
In this case, both Richlet and ZUL will work great. If you swap the url-pattern of servlet-mapping with richlet-mapping, only the Richlet will work well.
Note: Since ZK 7.0.0 release, when use ZK Richlet Filter, the url-pattern of the richlet-mapping should start with the prefix url-pattern in filter-mapping. For example,
In web.xml
<filter>
<filter-name>RichletFilter</filter-name>
<filter-class>org.zkoss.zk.ui.http.RichletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RichletFilter</filter-name>
<url-pattern>/zk/*</url-pattern>
</filter-mapping>
In zk.xml
<richlet-mapping>
<richlet-name>Test</richlet-name>
<url-pattern>/zk/foo/*</url-pattern>
</richlet-mapping>
The URL specified in the url-pattern
element must start with /
. If the URI ends with /*
, then it is matched to all request with the same prefix. To retrieve the real request, you can check the value returned by Page.getRequestPath() of the current page.
public void service(Page page) {
if ("/some/more/hi".equals(page.getRequestPath()) {
...
}
}
Version History
Version | Date | Content |
---|---|---|
ZK 7.0.0 | August 2013 | Support Richlet with Servlet Filter |