• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF inputText remembers old value instead of the new one

 
Ck Lee
Greenhorn
Posts: 2
  • 0
  • 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();
rep_id=request.getParameter("rep_id");
}

Then, in the inputText set method:

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

if (rep_id != null) {
inputText1.setValue(rep_id);
} 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 ?

Thanks

CK
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic