title: PrimeFaces tree selection is null
body: <p>I am using PrimeFaces 2.2.1 Tree component on Glassfish 3.1</p>
  
  <p>I am trying to set the selected node on the Tree to a TreeNode object in my backing bean, but it is always null.</p>
  
  <p>I asked for support on the PrimeFaces forum, but unfortunately received no reply.</p>
  
  <pre><code>&lt;p:tree id="contextTree" value="#{contextTreeBean.contextRoot}" var="node" selectionMode="single" selection="#{contextTreeBean.selectedNode}"&gt;
          &lt;p:treeNode&gt;
              &lt;h:outputText value="#{node.name}"/&gt;
          &lt;/p:treeNode&gt;
      &lt;/p:tree&gt;
      &lt;h:outputText id="output" value="#{contextTreeBean.output}"/&gt;
      &lt;p:commandButton id ="createButton" value="+" actionListener="#{contextTreeBean.createContext()}" update="contextTree, output"/&gt;
  
  
  @ManagedBean
  @RequestScoped
  public class contextTreeBean {
  
      @EJB
      private ContextFacadeLocal contextFacade;
      private Context context = new Context();
      private TreeNode contextRoot;
      private TreeNode selectedNode;
      private String output;
  
      /** Creates a new instance of contextTreeBean */
      public contextTreeBean() {
      }
  
      public void createContext() {
          output = selectedNode.getData().toString();
      }
  
      public String getOutput() {
          return output;
      }
  
      public void setOutput(String output) {
          this.output = output;
      }
  
      public TreeNode getSelectedNode() {
          return selectedNode;
      }
  
      public void setSelectedNode(TreeNode selectedNode) {
          this.selectedNode = selectedNode;
      }
  
      public Context getContext() {
          return context;
      }
  
      public void setContext(Context context) {
          this.context = context;
      }
  
      public ContextFacadeLocal getContextFacade() {
          return contextFacade;
      }
  
      public void setContextFacade(ContextFacadeLocal contextFacade) {
          this.contextFacade = contextFacade;
      }
  
      public TreeNode getContextRoot() {
          return contextRoot;
      }
  
      public void setContextRoot(TreeNode contextRoot) {
          this.contextRoot = contextRoot;
      }
  
      @PostConstruct
      private void postConstruct() {
          populateContextTree();
      }
  
      private void populateContextTree() {
          buildContextTree(new DefaultTreeNode("Root", null), contextFacade.findRootContexts());
      }
  
      private void buildContextTree(TreeNode parentNode, List&lt;Context&gt; children) {
          for (Context currentContextNode : children) {
              TreeNode tempNode = new DefaultTreeNode(currentContextNode, parentNode);
              buildContextTree(tempNode, currentContextNode.getChildren());
          }
          contextRoot = parentNode;
      }
  }
  </code></pre>