users@javaserverfaces.java.net

Re: JSF and validation

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Tue, 11 Dec 2007 08:58:43 -0800

� wrote:
> I have a screen with some inputtext boxes with some special validation I
> want to do on each of them (I am doing the function validation
> validator="#{somebean.somemethod}". The problem I am having is this, it
> seems that if the user does not make any changes and they just hit submit,
> jsf never goes into any of my validate methods. And when I put the
> required=true in the tag and does its own validation. What can I do?
>
 From the javadocs for UIInput.valiateValue():

If the valid property on this component is still
true, and the local value is not empty, call the
validate() method of each Validator
registered for this UIInput....

That said, required=true in only part of the validation. After the required
part is checked, any registered validators will be invoked.

If the default behavior isn't desired you can:

- create a custom component and override the behavior
- move your validation logic to take place within the action
of the form submission
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net
>
>