public class Validator extends ValidatorHandler
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.
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
deferred value expressions.
<o:validator validatorId="javax.faces.LongRange" minimum="#{item.minimum}" maximum="#{item.maximum}" />
The validator ID of all standard JSF 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="javax.faces.LongRange" minimum="#{item.minimum}" maximum="#{item.maximum}" message="Please enter between #{item.minimum} and #{item.maximum} characters" />
DeferredTagHandlerHelper
Modifier and Type | Class and Description |
---|---|
protected static class |
Validator.DeferredValidator
So that we can have a serializable validator.
|
delegateFactory
nextHandler, tag, tagId
Constructor and Description |
---|
Validator(ValidatorConfig config)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(FaceletContext context,
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(Application application,
String id)
|
TagAttribute |
getTagAttribute(String name)
Just return TagHandler#getAttribute() via a public method (it's by default protected and otherwise thus
unavailable inside collectDeferredAttributes().
|
protected TagHandlerDelegate |
getTagHandlerDelegate() |
boolean |
isDisabled(FaceletContext context) |
getValidatorConfig, getValidatorId
applyAttachedObject, getAttachedObjectHandlerHelper, getFor
applyNextHandler, createMetaRuleset, getBinding, getTag, getTagId, setAttributes
getAttribute, getRequiredAttribute, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
applyAttachedObject, getFor
public Validator(ValidatorConfig config)
config
- The validator config.public void apply(FaceletContext context, UIComponent parent) throws 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 FaceletHandler
apply
in class DelegatingMetaTagHandler
context
- The involved facelet context.parent
- The parent component to add the Validator
to.IOException
- If something fails at I/O level.public <T> T create(Application application, String id)
public TagAttribute getTagAttribute(String name)
getTagAttribute
in class DelegatingMetaTagHandler
name
- The attribute name.protected TagHandlerDelegate getTagHandlerDelegate()
getTagHandlerDelegate
in class ValidatorHandler
public boolean isDisabled(FaceletContext context)
isDisabled
in class DelegatingMetaTagHandler
Copyright © 2012–2014 OmniFaces. All rights reserved.