The richlet and richlet-mapping elements

To declare a richlet, you have to add the richlet element to zk.xml. You could specify any number of richlet elements. Each of them must have two child elements, richlet-name and richlet-class, and might have any number of the init-param child elements.

The class name specified in the richlet-class element must implement the org.zkoss.zk.ui.Richlet interface. The name and value specified in the init-param element can be retrieved when the init method of org.zkoss.zk.ui.Richlet is called.

<richlet><richlet-name>Test</richlet-name><richlet-class>org.zkoss.zkdemo.TestRichlet</richlet-class><init-param><param-name>any</param-name><param-value>any</param-value></init-param></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>                

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()) {    
        ...        
    }}