The <o:validator> is a taghandler that extends the standard <f:validator> tag family with support for deferred value
expressions in all attributes. In other words, the validator attributes are not evaluated anymore on a per view build time basis, but just on every access
like as with UI components and bean properties. This has among others the advantage that they can be evaluated on a per-iteration basis inside an iterating
component, and that they can be set on a custom validator without needing to explicitly register it in a tagfile.
When you specify for example the standard <f:validateLongRange> by validatorId="jakarta.faces.LongRange", then you'll be able
to use all its attributes such as minimum and maximum as per its documentation, but then with the possibility to supply deferred
value expressions.
<o:validator validatorId="jakarta.faces.LongRange" minimum="#{item.minimum}" maximum="#{item.maximum}" />
The validator ID of all standard Faces validators can be found in
their javadocs. First go to the javadoc of
the class of interest, then go to VALIDATOR_ID in its field summary and finally click the Constant Field Values link to see the value.
It is also possible to specify the validator message on a per-validator basis using the message attribute. Any "{0}" placeholder in the message
will be substituted with the label of the referenced input component. Note that this attribute is ignored when the parent component has already
validatorMessage specified.
<o:validator validatorId="jakarta.faces.LongRange" minimum="#{item.minimum}" maximum="#{item.maximum}"
message="Please enter between #{item.minimum} and #{item.maximum} characters" />
The <o:validator> is currently not compatible with validators which are managed via the managed=true attribute set on the
FacesValidator annotation, at least not when using Mojarra. Internally, the converters are wrapped in another instance which doesn't have the needed
setter methods specified. In order to get them to work with <o:validator>, the managed=true attribute needs to be removed, so
that OmniFaces ValidatorManager will automatically manage them.
| Info | Value |
|---|---|
| Validator ID | omnifaces.Validator |
| Handler Class | org.omnifaces.taghandler.Validator |
| Description | None |
| Name | Required | Type | Description |
|---|---|---|---|
binding | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| A ValueExpression that evaluates to an object that implements the jakarta.faces.validator.Validator interface. |
disabled | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| A boolean value enabling request based determination of whether or not this validator is enabled on the enclosing component. |
for | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| If present, this attribute refers to the value of one of the exposed attached objects within the composite component inside of which this tag is nested. |
message | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The validator message to be shown on failure. Any "{0}" placeholder in the message will be substituted with the label of the referenced input component. Note that this attribute is ignored when the parent component has already validatorMessage specified. |
validatorId | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| Validator identifier of the Validator to be created and registered. |
Output generated by Vdldoc View Declaration Language Documentation Generator.