Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.3.2.  < rich:beanValidator > available since 3.2.2

Starting from 3.2.2 GA version Rich Faces provides support for model-based constraints defined using Hibernate Validator. Thus it's possible to use Hibernate Validators the same as for Seam based applications.

The <rich:beanValidator> component is defined in the same way as any JSF validator. Look at the example below.

      <f:facet name="header">
            <h:outputText value="#{validationBean.progressString}" id="progress"/>
      <h:panelGrid columns="3">
            <h:outputText value="Name:" />
            <h:inputText value="#{}" id="name">
                  <rich:beanValidator summary="Invalid name"/>
            <rich:message for="name" />

            <h:outputText value="Email:" />
            <h:inputText value="#{}" id="email">
                  <rich:beanValidator summary="Invalid email"/>
            <rich:message for="email" />
            <h:outputText value="Age:" />
            <h:inputText value="#{validationBean.age}" id="age">
                  <rich:beanValidator summary="Wrong age"/>
            <rich:message for="age" />
            <f:facet name="footer">
                  <a4j:commandButton value="Submit" action="#{validationBean.success}" reRender="progress"/>

Please play close attention on the bean code that contains the constraints defined with Hibernate annotation which perform validation of the input data.

package org.richfaces.demo.validation;
import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.Max;
import org.hibernate.validator.Min;
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;
public class ValidationBean {
    private String progressString="Fill the form please";
    @Pattern(regex=".*[^\\s].*", message="This string contain only spaces")
    private String name;
    private String email;
    private Integer age;
    public ValidationBean() {
    /* Corresponding Getters and Setters */
    public void success() {
        setProgressString(getProgressString() + "(Strored successfully)");
    public String getProgressString() {
        return progressString;
    public void setProgressString(String progressString) {
        this.progressString = progressString;

The following figure shows what happens if validation fails

As you can see from the example that in order to validate the <rich:beanValidator> should be nested into a input JSF or RichFaces component.

The component has the only attribute - "summary" which displays validation messages about validation errors.

On RichFaces LiveDemo page you can see an example of <rich:beanValidator> usage and sources for the given example.