JSF - Validators

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.

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.

Documentation / Reference


Powered by ComboStrap