The richlet-mapping Element"
Line 14: | Line 14: | ||
</source> | </source> | ||
− | + | When mapping, you should consider with the <tt>servlet-mapping</tt> 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 <tt>/path/*</tt>, you may specify the servlet-mapping in web.xml as follows: | |
<source lang="xml" > | <source lang="xml" > | ||
Line 23: | Line 23: | ||
</source> | </source> | ||
− | and the richlet-mapping as follows: | + | and specify the richlet-mapping as follows: |
<source lang="xml" > | <source lang="xml" > | ||
Line 32: | Line 32: | ||
</source> | </source> | ||
− | In this case, both Richlet and ZUL will work great. If swap the servlet-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. |
The URL specified in the <tt>url-pattern</tt> element must start with <tt>/</tt>. If the URI ends with <tt>/*</tt>, 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. | The URL specified in the <tt>url-pattern</tt> element must start with <tt>/</tt>. If the URI ends with <tt>/*</tt>, 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. |
Revision as of 10:05, 28 July 2011
Once a richlet is declared, you could map it to any number of URL by use of 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 with 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.
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 |
---|---|---|