Implementing a Component Property
From Documentation
Revision as of 02:22, 8 July 2010 by Tmillsclare (talk | contribs) (Created page with '{{ZKComponentDevelopmentEssentialsPageHeader}} A property usually has a getter and a setter. The getter is straightforward: <source lang="java"> private String _value = ""; //a…')
A property usually has a getter and a setter. The getter is straightforward:
private String _value = ""; //a data member
public String getValue() {
return _value;
}
The setter is similar except we have to notify the client. This is achieved by using the AbstractComponent.smartUpdate(String, boolean) function.
public void setValue(String value) {
if (!_value.equals(value)) {
_value = value;
smartUpdate("value", _value);
}
}
The AbstractComponent.smartUpdate(String, boolean) function causes ZK Client Engine to call the setValue method of the peer widget (the first argument is the property name). Then, the widget can manipulate the DOM tree from there.