The org.zkoss.zk.ui.sys.PropertiesRenderer interface

From Documentation
Revision as of 10:23, 19 January 2022 by Hawk (talk | contribs) (correct highlight (via JWB))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


DocumentationZK Configuration Referencezk.xmlThe listener ElementThe org.zkoss.zk.ui.sys.PropertiesRenderer interface
The org.zkoss.zk.ui.sys.PropertiesRenderer interface


Listener:

org.zkoss.zk.ui.sys.PropertiesRenderer

A listener could implement PropertiesRenderer to generate application-specific client-side properties of a component.

Once registered, PropertiesRenderer.renderProperties(Component, ContentRenderer) will be invoked each time a component has rendered its client-side properties. The application-specific properties generated by this method will be sent with the default properties generated by the client. If there is a property with the same name, the default one will be evaluated first, and the the application-specific one.

For example, assume you have an implementation called foo.MyRenderer, then you could specify it in WEB-INF/zk.xml

<!-- in WEB-INF/zk.xml -->
<listener>
    <listener-class>foo.MyRenderer</listener-class>
</listener>

And, assume you'd like to generate an extra property if the component is a datebox, you could do as follows.

package foo;
import org.zkoss.zk.ui.sys.*;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.*;
public class MyRenderer implements PropertiesRenderer {
    public void render(Component comp, ContentRenderer renderer)
    throws java.io.IOException {
        if (comp instanceof Datebox) {
            renderer.render("myProp", myValue);
        }
    }
}

Instantiation: For better performance, a single instance of the given class is instantiated when registered. It is then shared in the whole application. Thus, the implementation must be thread safe.

Version History

Last Update : 2022/01/19


Version Date Content
5.0.7 April 2011 PropertiesRenderer was introduced.



Last Update : 2022/01/19

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