• Post Reply Bookmark Topic Watch Topic
  • New Topic

h:selectOneMenu validation (all in one)

 
Rob Ko
Greenhorn
Posts: 8
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey :)

Another quick question about jsf.

I'm having three drop downs (day, month and year) and I'm trying to create a validation class (see below).



and here the validation class:



Currently the variables are all null.

sorry for the messi code, I just got this project >.>

thanks in advance :)
greetings
Kaito

source: http://www.mkyong.com/jsf2/multi-components-validator-in-jsf-2-0/
 
Tim Holloway
Bartender
Posts: 18419
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Validators do not work well with multiple input controls as inputs. They are best reserved for single-control value validation. Cross-field validation is something that is more easily done within the action method. Although the problem with validation in action methods is that the bean has already been updated at that point.

The major fault you have is that you are treating month, day, and year as attributes of the year dropdown component, and they are not. They are each components in their own right (not attributes) and you'd have to use a find-component method to locate them in the component tree. Simple physical adjacency (sibling nodes) wouldn't be reliable, as unexpected unrelated components can also be present. Once you have found the component, you'd have to extract its value, which isn't as easy as you might think, since the "value" of a UIComponent is actually its EL expression value, not a simple value.
 
Rob Ko
Greenhorn
Posts: 8
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay I see ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!