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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:51:46+00:00 2026-06-13T19:51:46+00:00

I have a form which has a input text and a set of radio

  • 0

I have a form which has a input text and a set of radio buttons. When a radio button is clicked I am invoking a value change listener. Inside the value change listener I am printing the value user has entered in the input text field. But I always get the older value of the text field and not the new value which the user is entering. I understand that ValueChangeListener comes under the Validation cycle. But if I need to access the new value of the input field what should I do?
Note: The managed bean is request scope. If I change the scope to session, it works fine. Any explanation on this would be welcome.
The code in JSP is as below:

<h:form>
Enter name:<h:inputText value="#{employee.empId}"></h:inputText>
Choose option: <h:selectOneRadio onclick="this.form.submit()" 
            valueChangeListener="#{employee.check}" >
<f:selectItem itemLabel="one" itemValue="one"/>
<f:selectItem itemLabel="two" itemValue="two"/>
</h:selectOneRadio>
</h:form>
  • 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-13T19:51:47+00:00Added an answer on June 13, 2026 at 7:51 pm

    Your problem description (old value only available in request scope; and it “works” in session scope) matches with the case as if you would be accessing the property directly instead of getting it from the ValueChangeEvent. This is indeed not right.

    The ValueChangeEvent offers you getters to return the old and the new value. You should use it instead of accessing the property directly.

    public void check(ValueChangeEvent event) {
        Object oldValue = event.getOldValue();
        Object newValue = event.getNewValue();
        // ...
    }
    

    Update: as per comments, you’re actually interested in the value of the input field. This is only been set during update model values phase, which is after the validations phase, when the value change listener runs.

    Given that you’re using legacy JSF 1.2 and thus can’t use the JSF2 ajax awesomeness, then one of the ways to solve this is to manually queue the value change event to the invoke action phase so that you can get the submitted input text value.

    public void check(ValueChangeEvent event) {
        if (event.getPhaseId() != PhaseId.INVOKE_APPLICATION) {
            event.setPhaseId(PhaseId.INVOKE_APPLICATION);
            event.queue();
            return;
        }
    
        System.out.println(empId); // It's available in here.
    }    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox which has the code; <input type=text maxlength=5 size=2 value=1 id=paging_textbox>
I have a text input which has a default value password. When the user
I have a form 'ChallengeType'. Which has these fields: 1) Embedded form team1 input
I have WPF Form which has many buttons with the same code. Appearance of
I have a form which lets users input text snippets. So how can figure
I have this table where I can generate dynamic rows (which has input <type=text
I have a pretty big data entry form which has many text fields ,
I have some jQuery listeners setup which listen for form input on a type=text
I have one form which has two text fields. One is Price and another
I have a form which has three inputs when the page loads -- 2

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.