title: actionListener doesn't work, but the method does
body: <p>I have tested my method to add a value to the database and it works fine. However, when I try to use the method as an actionListener in a command button it doesn't work. Could anyone please explain what it is I have wrong? This is the method:</p>
  
  <pre><code>public void addToNetwork() {
  
      MindmapNode currentNode = this.selectedNode;
  
      this.user.setConnections( this.user.getConnections() + "-" + currentNode.getLabel() );
      this.userConn = Arrays.asList(this.user.getConnections().split("-"));
      this.setUserdetails( this.user );
  }
  </code></pre>
  
  <p>And this is the xhtml:</p>
  
  <pre><code>&lt;p:mindmap value="#{mmBean.root}" style="width:100%;height:600px" id="mindmap"&gt;
      &lt;p:ajax event="select" listener="#{mmBean.onNodeSelect}" immediate="true"      
           id="oneClick" oncomplete="options.show()"  /&gt;
  /p:mindmap&gt;            
  
  
  &lt;p:dialog widgetVar="options"&gt;
  
      &lt;p:panelGrid  id="optionspanel" columns="2"&gt;
          &lt;h:outputText value="Add this user to your network?"/&gt;
          &lt;p:commandButton value="Add" update="mindmap" actionListener="#{mmBean.addToNetwork}" onclick="options.hide()" id="btnAdd"/&gt;
      &lt;/p:panelGrid&gt;
  
  &lt;/p:dialog&gt; 
  </code></pre>
  
  <p>This is the method for onNodeSelect:</p>
  
  <pre><code>public void onNodeSelect(SelectEvent event) {
      MindmapNode node = (MindmapNode) event.getObject();
      this.setSelectedNode(node);
  }
  </code></pre>
  
  <p>Note that I easily force the add when they click, but I want to offer the user a bunch of other options as well, eventually.</p>
  
  <p>Could this be done by, say, setting a property within addToNetwork to being true when they click add? Basically I'm thinking of something like remoteCommand? I tried having the first command set a connect-property to true and then the remoCommand calling the method with an if loop to connect if that property was set to true. That didn't work.</p>
  
  <p>I suspect the problem is telling with maintaining in the object which node is the selectedNode, but I'm not sure. Any help would be great! </p>
  
  <p>Edit: The answer was to store the nodelabel in the database and then access it again from there. Quite simple, really. I think the object was being destroyed sometime between the selectedNode value being set and being called, but I'm not 100% sure on that. </p>