| Author |
Validation order when managed bean scope is request
|
Humberto Santana
Greenhorn
Joined: Dec 04, 2006
Posts: 5
|
|
Hello everybody
I have a jsf page that with 2 lists. A list of dates and a list of people.
But the list of people depends on the chosen date.
I use ajax4jsf to update people list when date changes, and it works fine.
But when I click on save button I get "Validation Error: Value is not valid" on people list.
It happens because validate tries do call people list before (or without) calling date list. As date list is null, the form gets the default value for date (not the chosen date). And with the wrong date, people list does not have the person I chose. That's why I get Validation Error.
When I put the managed bean on session it works. But I don't wanna do this.
Is there a way to force validation to call a method before validate?
Or, Is there a better way to do this?
Thanks in advance
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
|
When your listener sets up the new people list, null out the currently selected person property. That will cause the UI to render with the default person selection (which I usually make be "-- Select a Person --"). Since you're no longer referencing a value that's not in the (updated) selection list, and a null property is OK for output, that fixes your problem.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Humberto Santana
Greenhorn
Joined: Dec 04, 2006
Posts: 5
|
|
Thanks for your reply.
But the main problem is that even date list becomes null when I click on save button. So validation puts default value on date instead of chosen date.
I realized this problem when I put a breakpoint on getPeopleList and getDateList methods. Break point stops on getPeopleList and not on getDateList.
If validate was calling getDateList before getPeopleList I think it would work.
But since validate call getPeopleList first, the list of dates is null and chosen date is default. So, chosen person is without peopleList since it depends on chosen date.
When iI put managed bean on session scope it works because validation does not have to rebuid the list.
But I don't want to put managed bean on session.
Sorry for my bad english. I hope you understand.
Thanks in advance
|
 |
 |
|
|
subject: Validation order when managed bean scope is request
|
|
|