Version 8

    There are several attributes/API functions that may affect expanded/collapsed state of Tree Nodes.

     

    1.adviseNodeOpened attribute

     

    This attribute can be assigned to method binding on any bean that will follow the rules: method must accept parameter org.richfaces.component. UITree and return java.lang.Boolean. That method may use getTreeNode() method to get the current Tree Node and that returns an advise. Advise mean: return of Boolean.TRUE will expand node, Boolean.FALSE will collapse node, null value will not change the current node state. Note: if tree model components family (treeNodes or recursiveTreeNodes) is used than only getRowData() method can be used to obtain the current element; org.richfaces.model.TreeNode instances are absent in this configuration and getTreeNode() will always return null.

     

    2.StateAdvisor attribute

     

    This attribute can be set to value binding that points to instance of org.richfaces.component.state.TreeStateAdvisor. This interface has two methods: Boolean adviseNodeOpened(UITree tree) and Boolean adviseNodeSelected(UITree tree). You can use adviseNodeOpened() same way as it was described above. A state adviser attribute is of higher priority than adviseNodeOpened attribute.

     

    3.You can use methods on UITree to send expand/collapse events:

    public void queueNodeExpand(TreeRowKey rowKey);

    public void queueNodeCollapse(TreeRowKey rowKey)

    public void queueExpandAll()

    public void queueCollapseAll()

    These events will be executed on 5-th phase and may be skipped, if some errors happen (as usual for any Action Events).

    (see http://thomaswabner.wordpress.com/2008/09/09/expanding-richfaces-tree-an-datamodel-changes/)