title: Primefaces 3.4: Tree selectedNode is null
body: <p>I am new in Primefaces and I try to use the Primefaces Tree for several days now.
  Basically, I have a Tree. I attach to this tree a contextual menu. When I click on the contextual menu, a dialog window opens and display more details about the selected node of the tree. I try to reproduce the primefaces showcase basing on the Tree and the TreeTable example.</p>
  
  <p>When I run my project, I try to open the dialog window, I have this error in the debugger:</p>
  
  <pre><code>WARNING: /protected/treeonly.xhtml @34,91 value="#{folderManagedBean.selectedNode.data.name}": Target Unreachable, 'null' returned null
  javax.el.PropertyNotFoundException: /protected/treeonly.xhtml @34,91 value="#{folderManagedBean.selectedNode.data.name}": Target Unreachable, 'null' returned null
  </code></pre>
  
  <p>Please find below the JSF Page</p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui"&gt;
      &lt;h:head&gt;
          &lt;title&gt;Facelet Title&lt;/title&gt;
      &lt;/h:head&gt;
      &lt;h:body&gt;
  
          &lt;h:form id="form"&gt;  
  
              &lt;!--*********** Context Menu ***********--&gt;
              &lt;p:contextMenu for="folderTree"&gt;  
                  &lt;p:menuitem value="Rename Folder" update="folderPanel" oncomplete="folderDialog.show();" icon="ui-icon-plus"/&gt;
              &lt;/p:contextMenu&gt; 
  
              &lt;!--*********** Folder Tree ***********--&gt;
              &lt;p:tree style="border:none;" id="folderTree" value="#{folderManagedBean.root}" var="folder" selectionMode="single" selection="#{folderManagedBean.selectedNode}"&gt;  
                  &lt;p:treeNode expandedIcon="ui-icon-folder-open" collapsedIcon="ui-icon-folder-collapsed"&gt;  
                      &lt;h:outputText value="#{folder.name}" /&gt;  
                  &lt;/p:treeNode&gt;  
              &lt;/p:tree&gt;  
  
  
              &lt;!--*********** Dialog Box ***********--&gt;
              &lt;p:dialog header="New Folder" widgetVar="folderDialog" modal="true" resizable="false"  
                        showEffect="clip" hideEffect="fold"&gt;  
                  &lt;p:outputPanel id="folderPanel"&gt;  
                      &lt;h:panelGrid columns="2" cellpadding="4"&gt;  
                          &lt;h:outputText value="Folder Name:" /&gt;  
                          &lt;p:inputText value="#{folderManagedBean.selectedNode.data.name}"/&gt; 
                      &lt;/h:panelGrid&gt;  
                  &lt;/p:outputPanel&gt;
              &lt;/p:dialog&gt;  
  
  
          &lt;/h:form&gt;
  
  
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here the managed bean:</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class FolderManagedBean implements Serializable{
  
      @EJB
      private FolderBean folderBean;
  
      private Folder froot;  
      private TreeNode root;
  
      private TreeNode selectedNode;  
  
      public FolderManagedBean() {   
      }
  
      @PostConstruct
      public void initialize(){
          root = buildTree();
      }
  
      public TreeNode getRoot(){
          return root;
      }
  
  
      private TreeNode buildTree(){
          froot = folderBean.getRootFolder();
  
          root = new DefaultTreeNode("root", null);      
          TreeNode realRoot = new DefaultTreeNode(froot, root);
  
          for (Folder child : froot.getChildFolders()){
              TreeNode tnChild = new DefaultTreeNode(child, realRoot);
              tnChild.setParent(realRoot);
              buildTreeRecursively(tnChild);
          }        
          return root;     
      }
  
      private void buildTreeRecursively(TreeNode currentNode){
          Folder folder =  (Folder)(currentNode.getData());
          for(Folder child : folder.getChildFolders()){
              TreeNode tnChild = new DefaultTreeNode(child, currentNode);
              tnChild.setParent(currentNode);
  
              buildTreeRecursively(tnChild);
          }
      }
  
      public TreeNode getSelectedNode() {
          return selectedNode;
      }
  
      public void setSelectedNode(TreeNode selectedNode) {
          this.selectedNode = selectedNode;
      }
  }
  </code></pre>
  
  <p>Any help would be really appreciated.</p>