aspose file tools*
The moose likes JSF and the fly likes JSF validation - combining custom validator with tag validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF validation - combining custom validator with tag validator" Watch "JSF validation - combining custom validator with tag validator" New topic
Author

JSF validation - combining custom validator with tag validator

John Smith Jr
Greenhorn

Joined: Jan 12, 2010
Posts: 1
Hello,

Below you can find example code:
<h:inputText id="email" size="15" maxlength="15" required="true" value="#{RegisterBean.email}" validator="#{RegisterBean.validateEmail}">
<f:validateLength minimum="6" maximum="40"/>
</h:inputText>
<h:message for="email" />

I want to use tag validator to validate length and custom validator in the backing bean for further validation. The caveat is I want to display only one message in the message field. Right now when user inputs for example 3 characters into the email field then message from the backing bean is displayed next to the component and message from tag validator validateLength appears below the form. I want to have only one message, next to the validated component. How can I achieve that? What is the order of validation? I know that I can use messages field or incorporate all validation into the backing bean and get rid of the tag validator. I just would like to know if I can do it easier. Messages field is clumsy and I don't want to code something which is already supported by the framework. I'd appreciate your help.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF validation - combining custom validator with tag validator