• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF validation - combining custom validator with tag validator  RSS feed

John Smith Jr
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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: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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!