Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:28:35+00:00 2026-06-15T22:28:35+00:00

I have tested my method to add a value to the database and it

  • 0

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:

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 );
}

And this is the xhtml:

<p:mindmap value="#{mmBean.root}" style="width:100%;height:600px" id="mindmap">
    <p:ajax event="select" listener="#{mmBean.onNodeSelect}" immediate="true"      
         id="oneClick" oncomplete="options.show()"  />
/p:mindmap>            


<p:dialog widgetVar="options">

    <p:panelGrid  id="optionspanel" columns="2">
        <h:outputText value="Add this user to your network?"/>
        <p:commandButton value="Add" update="mindmap" actionListener="#{mmBean.addToNetwork}" onclick="options.hide()" id="btnAdd"/>
    </p:panelGrid>

</p:dialog> 

This is the method for onNodeSelect:

public void onNodeSelect(SelectEvent event) {
    MindmapNode node = (MindmapNode) event.getObject();
    this.setSelectedNode(node);
}

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.

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.

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!

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:28:36+00:00Added an answer on June 15, 2026 at 10:28 pm

    In contrary to the action method, the actionListener method must take an ActionEvent argument.

    You have 2 options:

    1. Use action instead.

      <p:commandButton ... action="#{mmBean.addToNetwork}" />
      
    2. Add that argument, even though you never use it.

      import javax.faces.event.ActionEvent;
      
      // ...
      
      public void addToNetwork(ActionEvent event) {
          // ...
      }
      

    See also:

    • Differences between action and actionListener
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My MySQL database can store the euro symbol just fine (as I have tested
I have tested this servlet and it works well, except in Google Chrome it
i have tested standardanalyzer with indexWriter and found that it automatically removes stopwords, however,
I have a repeat where the value loops through documents in the current database,
I wrote some code that should add database response to the List. it works
I have tested out hundreds of different codes, either they work and screw something
I have tested the below script on a demo page which is not using
I have tested my application on various mobile phones. My applications main functionality is
I have a secured (https) XML-RPC server written in python, and I have tested
i have made my custom Static Library (.a) successfully. i have tested it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.