I'm using Primefaces 6.1. The creation of the tree works fine, it also reacts on expanding the tree while clicking the triangle on the left. It also fires the event when clicking the node. But.... I would like to expand the tree when clicking the node. I'm not able to bring this to work.
This is the tree-code snippet:
<p:tree id="tree"
value="#{managedBeanFolder.root}"
var="node"
styleClass="tree-noborder"
selectionMode="single">
<p:ajax update=":folderListe:docListLatest" event="select" listener="#{managedBeanFolder.onNodeSelectListe}"/>
<p:treeNode>
<h:outputText value="#{node}" style="border:none" />
</p:treeNode>
</p:tree>
My ViewScoped ManagedBean looks like this
public void onNodeSelectListe(NodeSelectEvent event) {
RequestContext context = RequestContext.getCurrentInstance();
TreeNode selectedNode = (TreeNode) event.getTreeNode();
if (selectedNode != null) {
if (selectedNode.getChildCount() > 0) {
if (selectedNode.isExpanded()) {
selectedNode.setExpanded(false);
context.update("folderListe:tree");
} else {
selectedNode.setExpanded(true);
context.update("folderListe:tree");
}
}
}
}
I have checked, the code is executed. When I expand the tree by clicking the triangle, selectedNode.isExpanded() is true, when I collapse by clicking the triangle, the value is false. But the website is not updated.
What is wrong? Many thanks
update=":folderListe:docListLatest"does this include the tree? You need to update the tree. - Vsevolod Golovanov