• 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

JSF validation - combining custom validator with tag validator

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

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic