Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF inputText remembers old value instead of the new one  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSF page with a backing bean. The JSF page only has 2 components, an InputText with the readOnly = true
and a CommandButton that invokes an Action in the backing bean. The backing bean (Page1) is in Request scope.

I need to be able to set the values of the JSF based on a URL parameter (in this case set the value of the InputText)
and I did it as so in the bean's initialization method. The rep_id is a private String.

public Page1() {
HttpServletRequest request=(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();

Then, in the inputText set method:

public void setInputText1(CoreInputText inputText1) {
this.inputText1 = inputText1;

if (rep_id != null) {
} else {
rep_id = inputText1.getValue().toString();

System.out.println("Rep Id: " + inputText1.getValue());

Lastly, in the action method I have the following:

public String doAction() {
System.out.println("Action Rep Id: " + inputText1.getValue());
return null;

When run the page1.jspx JSF page using: /faces/page1.jspx?rep_id=xxx
it shows "xxx" in the inputText field.

Next when I run it using: /faces/page1.jspx?rep_id=yyy
it shows "yyy" in the inputText field and also all the debugging messages.
So far so good.

But if I click on the CommandButton next, the debugging message shows:

Action Rep Id: xxx

instead of the expected "yyy" which is what currently shown on the page1.jspx.

It seems to have cached the value and I cannot change it. Can anyone help me
on how I can permanently change the inputText value ?


He's giving us the slip! Quick! Grab this tiny ad!
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!