|
This corresponds to JSF component attribute validator.
One way of implementing this is to specify a method-binding expression that would invoke a method on the backing bean that will validate the component value.
Apart from designating a validator as an attribute, the association could be in form of nested components within other components. There are some standard validator components:
f:validateDoubleRange
f:validateLongRange
f:validateLength
Custom validators could be specified in the faces-config.xml and given symbolic names. They could then be associated with a component, using the f:validator component.
The table below shows dWebSpec standard validators and their correspondent validators on the JSF platform.
The list of the validator type is provided in the
overview section of the Element Descriptor.
The
implementation aspect is discussed here.
The
following are the mappings for dWebSpec validation types to JSF validations components. The dWebSpec types
are more concise; it would take considering both the validator types and conversion types to arrived at the
equivalent JSF validation components.
| Validators |
Conversion Type |
JSF Equivalents |
TypeValidator (On JSF platform, the converter validates and converts) |
string (default) |
| Credit card | t:validateCreditCard |
| Email | t:validateEmail |
| url | |
|
|
byte |
f:convertNumber |
| |
short |
f:convertNumber |
| |
integer |
f:convertNumber |
| |
long |
f:convertNumber |
| |
float |
f:convertNumber |
| |
double |
f:convertNumber |
| |
date |
f:convertDateTime |
| |
boolean |
* note that Boolean input is usually implemented with checkbox or select, both of which do not need validation
|
| RequiredValidator (required attribute) |
|
require attribute
|
| Range |
byte,short,integer |
f:validateLongRange |
| |
long |
f:validateLongRange |
| |
float |
f:validateLongRange |
| |
double |
f:validateLongRange |
| Regex |
|
t:validateRegExpr |
| MaxLength |
|
f:validateLength |
| MinLength |
|
f:validateLength |
| Equal |
|
t:validateEqual |
Custom validator could be registered and used on the page with the following tag. The registration aspects is
discussed under the subject of behavior-define descriptor:
f:validator
|