• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validation order when managed bean scope is request

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Humberto Santana
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic