HTML and CSS Reference
In-Depth Information
<h:commandButton value="#{bundle['application.subscribe']}"
<h:messages styleClass="errorMessage"/>
As we notice in the code listing, we did nothing special; we used the JSF required field validator with all of the
fields. It is important to note that all of the built-in or custom JSR 303 validators ( @Size and @EmailValidator ) will
be applied automatically to the JSF components without doing any extra steps.As shown in Figure 3-7 , Java Bean
Validation errors are automatically attached to the JSF <h:message> and <h:messages> components.
Figure 3-7. Java Bean Validation errors in the JSF message components
By default, all of the Java Bean Validation (JSR 303) validators will be enabled automatically in the JSF managed
beans; in order to disable this behavior, you can set the javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR
context param in the web.xml to true as shown:
One thing that is important to note is that Java Bean Validation is a standalone validation framework which is
not part of the JavaServer Faces framework (although there is a decent integration between them, as we see in the
subscriber application); this means that you need to provide a separate property file for the Java Bean Validation
messages. As per JSR 303, this property file should be named with its locale
variations for handling different locales, and the Java Bean Validation property files should be put under the default
package (the root of the class path) of the JSF application.
Search WWH ::

Custom Search