public class Validator
extends javax.faces.view.facelets.ValidatorHandler
<o:validator>
basically extends the <f:validator>
tag family with the
possibility to evaluate the value expression in all attributes on a per request basis instead of on a per view
build time basis. This allows the developer to change the attributes on a per request basis, such as the
disabled
attribute.
<o:validator validatorId="someValidatorId" disabled="#{param.disableValidation}" />
When you specify for example the standard <f:validateLongRange>
by
validatorId="javax.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
request based value expressions.
<o:validator validatorId="javax.faces.LongRange" minimum="#{item.minimum}" maximum="#{item.maximum}" />
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="javax.faces.LongRange" minimum="#{item.minimum}" maximum="#{item.maximum}" message="Please enter between #{item.minimum} and #{item.maximum} characters" />
Modifier and Type | Class and Description |
---|---|
protected static class |
Validator.RenderTimeValidator
So that we can have a serializable validator.
|
Constructor and Description |
---|
Validator(javax.faces.view.facelets.ValidatorConfig config)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(javax.faces.view.facelets.FaceletContext context,
javax.faces.component.UIComponent parent)
Create a
Validator based on the binding and/or
validatorId attributes as per the standard JSF <f:validator> implementation and
collect the render time attributes. |
<T> T |
create(javax.faces.application.Application application,
java.lang.String id)
|
javax.faces.view.facelets.TagAttribute |
getTagAttribute(java.lang.String name)
Just return TagHandler#getAttribute() via a public method (it's by default protected and otherwise thus
unavailable inside collectRenderTimeAttributes().
|
protected javax.faces.view.facelets.TagHandlerDelegate |
getTagHandlerDelegate() |
boolean |
isDisabled(javax.faces.view.facelets.FaceletContext context) |
getValidatorConfig, getValidatorId
applyAttachedObject, getAttachedObjectHandlerHelper, getFor
applyNextHandler, createMetaRuleset, getBinding, getTag, getTagId, setAttributes
getAttribute, getRequiredAttribute, toString
public Validator(javax.faces.view.facelets.ValidatorConfig config)
config
- The validator config.public void apply(javax.faces.view.facelets.FaceletContext context, javax.faces.component.UIComponent parent) throws java.io.IOException
Validator
based on the binding
and/or
validatorId
attributes as per the standard JSF <f:validator>
implementation and
collect the render time attributes. Then create an anonymous Validator
implementation which wraps
the created Validator
and delegates the methods to it after setting the render time attributes only
and only if the disabled
attribute evaluates true
for the current request. Finally set
the anonymous implementation on the parent component.apply
in interface javax.faces.view.facelets.FaceletHandler
apply
in class javax.faces.view.facelets.DelegatingMetaTagHandler
context
- The involved facelet context.parent
- The parent component to add the Validator
to.java.io.IOException
- If something fails at I/O level.public <T> T create(javax.faces.application.Application application, java.lang.String id)
public javax.faces.view.facelets.TagAttribute getTagAttribute(java.lang.String name)
getTagAttribute
in class javax.faces.view.facelets.DelegatingMetaTagHandler
protected javax.faces.view.facelets.TagHandlerDelegate getTagHandlerDelegate()
getTagHandlerDelegate
in class javax.faces.view.facelets.ValidatorHandler
public boolean isDisabled(javax.faces.view.facelets.FaceletContext context)
isDisabled
in class javax.faces.view.facelets.DelegatingMetaTagHandler