JSF - Validators

> Procedural Languages > Java > JavaServer Faces (JSF)

1 - About

Validators are used to validate the data that is received from the input components.

JavaServer Faces technology provides a set of standard classes and associated tags that page authors and application developers can use to validate a component’s data.

Advertising

3 - Referencing a Method That Performs Validation

If the input of one of the components on your page is validated by a managed bean method, refer to the method from the component’s tag by using the validator attribute.

<h:inputText id="myId" 
    value="#{myManagedBean.userNumber}" 
    required="true" size="3" 
    disabled="#{myManagedBean.number eq myManagedBean.userNumber}"
    validator="#{myManagedBean.validateNumberRange}">
</h:inputText>

where the managed bean method validateNumberRange verifies that the input value is within the valid range.

4 - Documentation / Reference