title: How to pass variables from backing bean in primefaces
body: <p>I am unable to pass and then retrieve variable from a backing bean. My add() function is called when a tree node is selected:</p>
  
  <pre><code>public void add(TreeNode selectedTreeNode) {
      setMyid(((MyClass) selectedTreeNode.getData()).getId());
  
      System.out.println("id : " + getMyid());
  
      RequestContext.getCurrentInstance().execute("PF('dlgVar').show()");
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public String saveAction() {
      String myid = FacesContext.getCurrentInstance().
          getExternalContext().getRequestParameterMap().get("myid");
      System.out.println("myid : " + myid);
  }
  
  public void setMyid(String myid) {
     this.myid = myid;
  }
  
  public String getMyid() {
     return myid;
  }
  </code></pre>
  
  <p>The dialog is:</p>
  
  <pre><code>&lt;p:dialog id="dlgId" widgetVar="dlgVar" dynamic="true"&gt;
      &lt;h:form&gt;
          &lt;h:panelGrid columns="1"&gt; 
              &lt;h:outputLabel for="nametext" value="Name" /&gt;
             &lt;p:inputText id="nametext" value="#{myBean.name}" /&gt;
          &lt;/h:panelGrid&gt;
  
          &lt;p:commandButton value="Save" actionListener="#{myBean.saveAction}" &gt;
             &lt;f:param name="myid" value="#{myBean.myid}" /&gt;
          &lt;/p:commandButton&gt;
      &lt;/h:form&gt;
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>The id printed in saveAction() is null but it is not null when set in add().</p>
  
  <p>How can I set myid from backing bean so that it is correctly passed back to saveAction()?</p>