public abstract class AbstractValidator extends AbstractUtilities implements javax.faces.validator.Validator
Abstract base class for validators that use Apache Commons Validator as their foundation.
| Modifier and Type | Field and Description |
|---|---|
protected static String |
ARG_VALUE
Variable name in a
vars map representing the argument
that was being evaluated, and should be included in any error message. |
protected static ConverterHelper |
helper
Converter helper instance we can use in the
convert()
method implementation. |
protected static String |
MAXIMUM_VALUE
Variable name in a
vars map representing the maximum
value that should be accepted by this Validator. |
protected static String |
MINIMUM_VALUE
Variable name in a
vars map representing the minimum
value that should be accepted by this Validator. |
protected static String |
SUBMITTED_VALUE
Variable name in a
vars map representing the submitted
value that should be validated by this Validator. |
DEFAULT_RESOURCE_BUNDLE| Constructor and Description |
|---|
AbstractValidator() |
| Modifier and Type | Method and Description |
|---|---|
protected ShaleValidatorAction[] |
actions(javax.faces.context.FacesContext context,
String type)
Return an array of
ShaleValidatorActions to execute
for a given validation, starting with the configured dependent
actions, and ending with the action corresponding to the specified
action type. |
protected Object |
convert(javax.faces.context.FacesContext context,
Object value,
Class type)
Use the registered converters to convert the specified value
to the specified type.
|
boolean |
isClient()
Return a flag describing whether this validator should be enforced
on the client side or not.
|
protected org.apache.commons.validator.ValidatorResources |
resources(javax.faces.context.FacesContext context)
Return the
ValidatorResources that describe the
validation rules to be enforced by this application. |
void |
restoreState(javax.faces.context.FacesContext context,
Object state) |
Object |
saveState(javax.faces.context.FacesContext context) |
void |
setClient(boolean client)
Set a flag describing whether this validator should be enforced
on the client side or not.
|
abstract void |
validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
Perform the correctness checks implemented by this
Validator against the specified UIComponent. |
protected void |
validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value,
String type,
Map vars)
Perform a validation using the specified Commons Validator type.
|
getMessage, isTransient, message, message, message, setMessage, setTransientprotected static final String ARG_VALUE
Variable name in a vars map representing the argument
that was being evaluated, and should be included in any error message.
Typically, this will be either the value itself or a user-friendly
(localized) field label.
protected static final String MAXIMUM_VALUE
Variable name in a vars map representing the maximum
value that should be accepted by this Validator.
protected static final String MINIMUM_VALUE
Variable name in a vars map representing the minimum
value that should be accepted by this Validator.
protected static final String SUBMITTED_VALUE
Variable name in a vars map representing the submitted
value that should be validated by this Validator.
protected static final ConverterHelper helper
Converter helper instance we can use in the convert()
method implementation.
public boolean isClient()
Return a flag describing whether this validator should be enforced
on the client side or not. Default is true.
public void setClient(boolean client)
Set a flag describing whether this validator should be enforced on the client side or not.
client - The new client enforcement flagpublic abstract void validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
throws javax.faces.validator.ValidatorException
Perform the correctness checks implemented by this
Validator against the specified UIComponent.
If any violations are found, a ValidatorException
will be thrown containing the FacesMessage
describing the failure.
IMPLEMENTATION NOTE: Unlike earlier implementations of Shale Validator integration, validators that subclass this class do not support the option to skip server side validation.
validate in interface javax.faces.validator.Validatorcontext - FacesContext for the current requestcomponent - UIComponent we are checking for correctnessvalue - The value to validatejavax.faces.validator.ValidatorException - if validation failsNullPointerException - if context
or component is nullpublic void restoreState(javax.faces.context.FacesContext context,
Object state)
restoreState in interface javax.faces.component.StateHolderrestoreState in class AbstractUtilitiespublic Object saveState(javax.faces.context.FacesContext context)
saveState in interface javax.faces.component.StateHoldersaveState in class AbstractUtilitiesprotected ShaleValidatorAction[] actions(javax.faces.context.FacesContext context, String type)
Return an array of ShaleValidatorActions to execute
for a given validation, starting with the configured dependent
actions, and ending with the action corresponding to the specified
action type. If there is no defined action with the specified
type, return null.
context - FacesContext for the current requesttype - Type of the validator action for which to return actionsprotected Object convert(javax.faces.context.FacesContext context, Object value, Class type)
Use the registered converters to convert the specified value to the specified type.
context - FacesContext for the current requestvalue - Value to be convertedtype - Type to which the value should be convertedprotected org.apache.commons.validator.ValidatorResources resources(javax.faces.context.FacesContext context)
Return the ValidatorResources that describe the
validation rules to be enforced by this application.
context - FacesContext for the current requestprotected void validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value,
String type,
Map vars)
throws javax.faces.validator.ValidatorException
Perform a validation using the specified Commons Validator type.
context - FacesContext for the current requestcomponent - UIComponent whose value is being validatedvalue - The value being validatedtype - Type of validation to be performedvars - Mutable map of values to be passed in to the validationjavax.faces.validator.ValidatorException - if a validation error occursCopyright © 2004-2013 Apache Software Foundation. All Rights Reserved.