Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is value not part of a component's state?  RSS feed

 
karl narkar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, A very fundamental question about JSF. I was expecting the value to be a part of the component's saved state, but apparently it's not.

So my question is - why is value not considered as a part of the state of a UI Component?

Let me illustrate with an example

I have:
<h:inputText value="#{helloworld.name}" valueChangeListener="#{helloworld.processValueChanged}" />

And I've deliberately declared name as static for EXPERIMENTAL purposes.

public class HWBean {
private static String name;
...
public void processValueChanged(javax.faces.event.ValueChangeEvent valueChgEvent) {
System.out.println("Comes here ");
}

}

So if i open two browser windows and manipulate the input text, I find that the way processValueChanged works this way:
Window 1 Input: hello1 -> "Comes here "
Window 2 Input: hello1 -> "Comes here " NOT DISPLAYED
Window2 Input: hello2 -> "Comes here "
Window1 Input: hello2 -> "Comes here " NOT DISPLAYED

What this seems to suggest is that value is not sent as a part of the state of the component, but rather evaluated on every request from the backing bean.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it saves the binding - you did set a binding as the value attribute.
 
karl narkar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the binding is value.

So what would I need to do if I had to also ensure that the value got saved as a part of the component state?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!