Hi all,
I would like to expand or collapse when selecting a node in the tree (not just, when clicking the little graphic left beside the node).
I realised that with this code snippets:
xhtml:
<rich:tree switchType="ajax"
icon="img/folder.png" iconLeaf="img/folder.png"
ajaxSubmitSelection="true" reRender="wholeContent"
nodeSelectListener="#{fileSystemBean.processSelection}">
<rich:recursiveTreeNodesAdaptor
roots="#{fileSystemBean.sourceRoots}" var="item"
nodes="#{item.nodes}" />
</rich:tree>public void processSelection(NodeSelectedEvent event) {
UITree tree = (UITree) event.getComponent();
this.selectedNode = (FileSystemNode) tree.getRowData();
this.selectedNode.setExpanded(!this.selectedNode.isExpanded());
try {
if(this.selectedNode.isExpanded()) {
tree.queueNodeExpand((TreeRowKey)tree.getRowKey());
} else {
tree.queueNodeCollapse((TreeRowKey)tree.getRowKey());
}
} catch (IOException e) {
log.error(e);
// dann eben nicht.
}
}