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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:01:54+00:00 2026-06-14T20:01:54+00:00

I have multiple input field with a p:ajax with a listener. They all connect

  • 0

I have multiple input field with a p:ajax with a listener. They all connect to the same listener. How can I know what component triggerd the listener?

<h:inputText id="postalCode" size="20" value="# businessPartner.primaryAddress.postalCode}" 
<p:ajax event="change" listener="#{businessPartner.primaryAddress.retrievePostalCodeCity}"  >
</p:ajax>  
</h:inputText>

<h:inputText id="city" size="60" value="# businessPartner.primaryAddress.city}" 
<p:ajax event="change" listener="#{businessPartner.primaryAddress.retrievePostalCodeCity}"  >
</p:ajax>  
</h:inputText>



public void retrievePostalCodeCity() throws MWSException {
    int country = address.getCountryId();
    String postalCode = address.getPostalCode();
    String city = address.getCity();
}

I have this problem because I used to use a4j ajax, but I’m moving the project to fully primefaces and no longer richfaces. The listener to a4j has an AjaxBehaviorEvent event and there I could do event.getComponent().getId()

How can I do the same with prime ajax?

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

    The AjaxBehaviorEvent is not specific to RichFaces. It’s specific to JSF2 itself. So you can just keep using it in PrimeFaces.

    public void retrievePostalCodeCity(AjaxBehaviorEvent event) {
        UIComponent component = event.getComponent();
        // ...
    }
    

    As an alternative, or for the case that it’s really not possible elsewhere, you could always use the new JSF2 UIComponent#getCurrentComponent() method.

    public void retrievePostalCodeCity() {
        UIComponent component = UIComponent.getCurrentComponent(FacesContext.getCurrentInstance());
        // ...
    }
    

    By the way, the very same construct should work just fine with JSF2’s own <f:ajax>. I do not see any reason to use <p:ajax> here. It would however be the only way if you were actually using a PrimeFaces component such as <p:inputText>.


    Unrelated to the concrete problem, the event="change" is the default already. You can just omit it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select input field in multiple properties. I have to validate (empty
I have a structure which can have multiple levels e.g. <li> <a class=viewdetails></a> <input
Possible Duplicate: jQuery multiple class selector I have an input field '#q' where a
I would like to have a search box input field that flashes multiple default
I have multiple input fields on my page. I Regex them with a css
I have multiple input text fields grouped in divs: <div class=container0> <input class=containerItem0 name=containerItem[0][0]
I have multiple input textboxes in my page. I want to reset particular text
I have form with multiple input type=radio with text next to them. I want
I have multiple pdf files. Based on user input i am loading the pdf
I have an HTML form that needs multiple submit buttons, like this: <input type=submit

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.