JSF/Seam - new component instance on submit?
Posted
by purecharger
on Stack Overflow
See other posts from Stack Overflow
or by purecharger
Published on 2010-03-23T16:45:36Z
Indexed on
2010/03/23
18:43 UTC
Read the original article
Hit count: 357
And my confusion with JSF continues. This is a continuation of a question asked yesterday, but I feel it warrants a new question. I have a single seam component that expects a URL parameter to be injected for retrieving a List<String>
from a method. This works perfectly on the first navigation to the page. The List
is used to display many different selectOneRadio
groups that populate a <h:form/>
.
Now on the submit, I cannot get the URL parameter to be injected or otherwise set on the component! Adding <h:inputHidden/>
causes FacesExceptions to be thrown.
Then I tried setting the List
as an instance variable on the object, and when the subsequent call is made on the submit (which I also do not understand why that is done) I check to see if the variable is non-null: if it isn't, return it.
Now I found that a new instance of the component is created on submit!!!
getList() called
this.toString(): .BeanAction@5fd98420
#### This is when submit is clicked
getList() called
this.toString(): .BeanAction@22aacbce
The component has the following annotations:
Stateful
@Scope(ScopeType.CONVERSATION)
@Name("bean")
@Restrict("#{identity.loggedIn}")
Can someone explain why there is a new instance of the component created? I'm really not quite sure how to go about handling this. I thought the hidden parameter would work, because that is how I would do it with straight HTML, and I'm a little surprised that its not working for JSF/Seam.
© Stack Overflow or respective owner