| Tree is a JSF component implementation for
org.zkoss.zul.Tree ,
This class also implements
javax.faces.component.EditableValueHolder .
That means you can use bidirection value binding, immediate, required, converter, validator, valueChangeListener features on this component.
To use those features, you must decleare a namespace of "http://java.sun.com/jsf/core"
with a prefix (say 'f' in below example), add attribute of those feature with this namespace
(for example f:required="true")in you jsf page.
For more detail of EditableValueHolder features of JSF, you can refer to http://java.sun.com/products/jsp/
You must assign a value on each treeitem, so that, when page submit those value,
tree will decode the request parameter and set back to your bean.
You must assign a value on each treeitem, so that, after user select treeitem and submitting,
tree will decode the request parameter and set back the submitted value to your bean.
When listbox set multiple to false(single selection), then
the default binding value of this component is
java.lang.String .
When listbox set multiple ot true(multiple selection, then
the default binding value of this component is
java.lang.String array.
Example of use bidirection value binding:
<z:tree name="role1" id="tree" f:value="#{SelectionTestBean.selection}">
<z:treechildren>
<z:treeitem value="1">
<z:treerow><z:treecell label="Item 1" /></z:treerow>
</z:treeitem>
<z:treeitem value="2">
<z:treerow>
<z:treecell label="Item 2" />
</z:treerow>
<z:treechildren>
<z:treeitem value="3">
<z:treerow>
<z:treecell label="Item 2.1" />
</z:treerow>
<z:treechildren>
<z:treeitem value="4">
<z:treerow>
<z:treecell label="Item 2.1.1" />
</z:treerow>
</z:treeitem>
</z:treechildren>
</z:treeitem>
</z:treechildren>
</z:treeitem>
</z:treechildren>
</z:tree>
Example of using immediate:
<z:tree f:immediate="true" />
Example of using required:
<z:tree f:required="true" />
Example of using converter:
<z:tree f:converter="yourBean.convertMethod"/>
or
<z:tree >
<f:converter converterId="yourConverterId"/>
</z:tree>
Example of using validator:
<z:tree f:validator="yourBean.validateMethod"/>
or
<z:tree >
<f:validator validatorId="yourValidatorId"/>
</z:tree>
Example of using converter:
<z:tree >
<f:valueChangeListener type="your.ValueChangeListener"/>
</z:tree>
In some application server which doesn't support attribute namespace you can use attribute prefix 'f_' to replace attribute namespace
For example,
<z:tree f_value="#{yourBean.value}" />
This component should be declared nested under
org.zkoss.jsf.zul.Page .
To know more ZK component features you can refer to http://www.zkoss.org/
author: Dennis.Chen See Also: org.zkoss.zul.Tree See Also: javax.faces.component.EditableValueHolder |