aspose file tools*
The moose likes JSF and the fly likes Validation error while trying to change a value in a request scope bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Validation error while trying to change a value in a request scope bean" Watch "Validation error while trying to change a value in a request scope bean" New topic
Author

Validation error while trying to change a value in a request scope bean

Marcos APS
Greenhorn

Joined: Mar 09, 2009
Posts: 5
- JBoss 4.2.3.GA
- JSF 1.2_09-b01-BETA1 (Mojarra)
- Java 5 Update 17

Hello, everybody!

I'm having the following problem in my JSF web application:

I have a request scope backing bean. The first time this bean is loaded (I check
this with the ResponseStateManager.isPostBack() method) I fill a list of SelectItem
instances that are to be displayed in the JSF page in a <h:selectOneMenu> component.
The list goes, of course, to the <h:selectOneMenu>'s <f:selectItems> facet child
component. In the constructor I also define the value that goes to the value property
of the <h:selectOneMenu> component. This value is a property in the backing bean, as
is the list of SelectItem instances. Until now we have something like this:

The backing bean declaration in faces-config.xml:


The relevant parts of the JSF page:


The relevant parts of the backing bean class:


But when the user submits the form and the bean constructor is called again
(this time the method ResponseStateManager.isPostBack() returns true),
in the else block in the constructor above, I need to fill fSetoresOrigem with
other values and also the fSetorOrigem field because, of course, the fSetorOrigem
field has to be a valid value that exists in the new fSetoresOrigem list.
JSF is not complaining about the change to the list items, but it is complaining
to the change to the fSetorOrigem field (the list value), even though it is a
valid value present in the list. So I'm getting this error message:



I suppose that JSF is comparing the new value of the field fSetorOrigem with the value
it has in the view state. As the value is different it is raising the error. That's
what I suppose. But am I not able the change the value in the postback? I've already
checked and the value is valid. It corresponds to a value that exists in the list.
I really need a solution to this problem as I'm stuck with this and can't proceed until
I find a solution to this. What I am doing wrong and how can I solve this?

Thank you very much.

Marcos
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This topic is crossposted at the Sun forum a few hours ago.
Please read this: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
Marcos APS
Greenhorn

Joined: Mar 09, 2009
Posts: 5
Bauke Scholtz wrote:This topic is crossposted at the Sun forum a few hours ago.
Please read this: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites


I also posted my question here because this is an important issue to me and I haven't got any answer from the other forum until now. I think that posting my question in more than one forum increases my change to get an answer. It's really not my intention to upset anyone with this. I just want a answer to my problem.

Marcos
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation error while trying to change a value in a request scope bean