After implementing the richlet, you can define the richlet in zk.xml with the following statement.
<richlet> <richlet-name>Test</richlet-name><richlet-class>org.zkoss.zkdemo.TestRichlet</richlet-class> </richlet>
Once declaring a richlet, you can 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>
By default, richlets is disabled. To enable richlets, you have to add the following declaration to web.xml. Once enabled, you can add as many as richlets you want without modifying web.xml anymore.
<servlet-mapping><servlet-name>zkLoader</servlet-name><url-pattern>/zk/*</url-pattern></servlet-mapping>
Then, you can visit http://localhost/ zk /test to request the richlet.
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 the getRequestPath method of the current page.
public void service(Page page) { if ("/some/more/hi".equals(page.getRequestPath()) { ... }}
Tip: By specifying /* to url-pattern, you can map all unmatched URL to the mapped richlet.