title: Expand Primefaces Tree on selection
body: <p>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.</p>
  
  <p>This is the tree-code snippet:</p>
  
  <pre><code>&lt;p:tree id="tree"
          value="#{managedBeanFolder.root}"
          var="node"
          styleClass="tree-noborder"
          selectionMode="single"&gt;
      &lt;p:ajax update=":folderListe:docListLatest" event="select" listener="#{managedBeanFolder.onNodeSelectListe}"/&gt;
      &lt;p:treeNode&gt;
          &lt;h:outputText value="#{node}" style="border:none" /&gt;
      &lt;/p:treeNode&gt;
  &lt;/p:tree&gt;
  </code></pre>
  
  <p>My ViewScoped ManagedBean looks like this</p>
  
  <pre><code>public void onNodeSelectListe(NodeSelectEvent event) {
      RequestContext context = RequestContext.getCurrentInstance();
      TreeNode selectedNode = (TreeNode) event.getTreeNode();
      if (selectedNode != null) {
          if (selectedNode.getChildCount() &gt; 0) {
              if (selectedNode.isExpanded()) {
                  selectedNode.setExpanded(false);
                  context.update("folderListe:tree");
              } else {
                  selectedNode.setExpanded(true);
                  context.update("folderListe:tree");
              }
          }
      }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>What is wrong?
  Many thanks</p>