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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:02:19+00:00 2026-05-31T17:02:19+00:00

I have an Employee object I am showing in inputtext. For example, the firstname

  • 0

I have an Employee object I am showing in inputtext.
For example, the firstname of the employee is shown in an inputtext. When the value of this firstname changes it calls a method. Before this is done I want to call a method which saves the ID of the employee in the managedbean so I know which employee needs to be changed.
How do I do this, I got this so far:

<h:outputText value="First name:"/>
<p:inplace id="firstname" editor="true">
     <p:ajax event="save" onsuccess="#{employeeController.saveName()}"/>
     <p:inputText id="firstName" value="#{emp.firstName}"  
                  required="true" label="text"
                  valueChangeListener="#{employeeController.firstNameChanged}">
     <p:ajax event="valueChange" listener="#{employeeController.onValueChangedStart}"/>
     </p:inputText>
</p:inplace>

I guess I should pass the ID with the onValueChangedStart or firstNameChanged method. How do I do this? Or is there a better way to do this? There is a getter for the emp. So #{emp}.id to get 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-05-31T17:02:20+00:00Added an answer on May 31, 2026 at 5:02 pm

    Assuming that you’re indeed inside a repeating component where #{emp} is been exposed by its var attribute, you could just grab it from the EL scope inside the value change listener as follows:

    FacesContext context = FacesContext.getCurrentInstance();
    Employee employee = context.getApplication().evaluateExpressionGet(context, "#{emp}", Employee.class);
    Long id = employee.getId();
    // ...
    

    Alternatively, if you wrap the value of the <h:dataTable> inside a DataModel<Employee>, then you can obtain the current row as follows:

    Employee employee = model.getRowData();
    Long id = employee.getId();
    // ...
    

    Unrelated to the concrete problem, it’s unnecessary to have two listener methods for the value change. Note that the valueChangeListener gives you the opportunity to get both the old and new value by the event and the p:ajax listener not, the new value is already been set as model value at that point. If you need both the old and new value, remove the listener attribute of <p:ajax>. The event="valueChange" is by the way the default event already, so just remove it as well.

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

Sidebar

Related Questions

Assume I have a business object like this, class Employee { public string name;
Hi I'm have an object model with an Employee and EmployeeWorksiteReference (cause it's an
I have class Employee which is something like this. class Emp { int EmpID;
I am trying out EF 4.0.I have an Employee Object and using EF I
If I have created the following Employee object (simplified)... public class Employee { public
Suppose I have an Employee object with the following properties: string Name { get;
In the following scenario, you have a business object called Employee that contains all
Let's say I have the following: class Employee(models.Model): firstName = models.CharField(max_length = 30) lastName
I have a Create New Employee ASP.Net MVC form. My complex object is an
I have a custom employee object in the web service as a type. It

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.