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 8678137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:38:11+00:00 2026-06-12T20:38:11+00:00

I have an actionListener method in my managed bean which is called by many

  • 0

I have an actionListener method in my managed bean which is called by many command buttons.

public void verifyTestDisponibility(ActionEvent actionEvent) {
    if (button1 clicked) {
        // ...
    }
    if (button2  clicked) {
        // ...
    }
}

The part I’m stucking at is identifying the clicked command button. How can I identify it?

  • 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-12T20:38:12+00:00Added an answer on June 12, 2026 at 8:38 pm

    You can use it like this

    In xhtml page we can use a <h:commandButton> tag with actionListener

    <h:commandButton id="btn1" action="#{yourBean.method}" value="ButtonValue"
       actionListener="#{yourBean.commandClicked}"></h:commandButton>
    

    In your managed bean

    private String buttonId;
    /* getters and setters for buttonId goes here */
    
    public void commandClicked(ActionEvent event) {
      /* retrieve buttonId which you clicked */
      buttonId = event.getComponent().getId();
    
      /*check for which button you clicked*/
      if(buttonId.equals("btn1")){
    
      }else{
    
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ActionListener actionListenerRing = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { defined
I have something like the code below: for(int i=0;i<10;i++){ button=new JButton(buttons[i]); button.addActionListener(new ActionListener(){ public
i have a xhtml popup page which has two buttons.The two buttons have actionListener
I have the following code: public class Test extends JFrame implements ActionListener{ private static
Let's say I have a button called button1. If I want to create an
I have a class SaveFile implementing ActionListener. The method in it takes a string
HI, I have a doubt on calling the ActionListener method in the JSF beans.
I have a view-scoped bean ManageFoo.java: @ManagedBean(name = ManageFoo) @ViewScoped public class ManageFoo {
I have a method which brings up a transparent window overlay so I can
In a backing bean's @PostConstruct method, I make a call to an EJB which

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.