This subsection describes procedures for using Bean Validation from JSF.
The following conditions must be satisfied to perform the validation processing using Bean Validation in JSF:
The validation operations of the Bean Validation function vary depending on the value of the context parameter provided by JSF. The operations change as described in the following table depending on the value specified for javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR and the presence or absence of the <f:validateBean> tag for the ManagedBean variable that defines the annotation for Bean Validation.
Table 10-4 Relationship of the value specified for javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR and the validation processing
Value specified for javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR | Input value Specification of the <f:validateBean> tag (when disabled attribute is not specified) | Validation by Bean Validation |
---|---|---|
true | Yes | Yes |
No | No | |
false | Yes | Yes |
No | Yes | |
If value is not specified (default) | Same as when false is specified | Same as when false is specified |
For details on how to use the <f:validateBean> tag, see the standard specifications for JSF. For details on how to define validation for the ManagedBean variable, see the standard specifications for Bean Validation.
The following is an example implementation of using Bean Validation from JSF.
The first example shows an implementation of the Facelets page that registers the information for which validation is required.
<f:view> |
The next example shows an implementation of the validation definition for the ManagedBean variable that stores the data to be validated.
@ManagedBean(name="personalData") |