This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
Greenhorn
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();
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!