javax.faces.validator
Class BeanValidator

java.lang.Object
  extended by javax.faces.validator.BeanValidator
All Implemented Interfaces:
EventListener, PartialStateHolder, StateHolder, Validator

@JSFValidator(name="f:validateBean",
              bodyContent="empty")
@JSFJspProperty(name="binding",
                returnType="javax.faces.validator.BeanValidator",
                longDesc="A ValueExpression that evaluates to a BeanValidator.")
public class BeanValidator
extends Object
implements Validator, PartialStateHolder

BeanValidator is a Validator that doesn't do any validation itself, but delegates validation logic to Bean Validation.

Since:
2.0
Version:
$Revision: 1298644 $ $Date: 2012-03-08 18:00:23 -0500 (Thu, 08 Mar 2012) $
Author:
Jan-Kees van Andel (latest modification by $Author: lu4242 $)

Field Summary
static String DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME
          If this init parameter is present, no Bean Validators should be added to an UIInput by default.
static String EMPTY_VALIDATION_GROUPS_PATTERN
          This regular expression is used to match for empty validation groups.
static String MESSAGE_ID
          The message ID for this Validator in the message bundles.
static String VALIDATION_GROUPS_DELIMITER
          This is used as a separator so multiple validation groups can be specified in one String.
static String VALIDATOR_FACTORY_KEY
          The key in the ServletContext where the Bean Validation Factory can be found.
static String VALIDATOR_ID
          Converter ID, as defined by the JSF 2.0 specification.
 
Fields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID
 
Constructor Summary
BeanValidator()
           
 
Method Summary
 void clearInitialState()
          
 String getValidationGroups()
          Get the Bean Validation validation groups.
 boolean initialStateMarked()
          
 boolean isTransient()
          
 void markInitialState()
          
 void restoreState(FacesContext context, Object state)
          
 Object saveState(FacesContext context)
          
 void setTransient(boolean isTransient)
          
 void setValidationGroups(String validationGroups)
          Set the Bean Validation validation groups.
 void validate(FacesContext context, UIComponent component, Object value)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATOR_ID

public static final String VALIDATOR_ID
Converter ID, as defined by the JSF 2.0 specification.

See Also:
Constant Field Values

MESSAGE_ID

public static final String MESSAGE_ID
The message ID for this Validator in the message bundles.

See Also:
Constant Field Values

DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME

@JSFWebConfigParam(defaultValue="true",
                   expectedValues="true, false",
                   since="2.0",
                   group="validation")
public static final String DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME
If this init parameter is present, no Bean Validators should be added to an UIInput by default. Explicitly adding a BeanValidator to an UIInput is possible though.

See Also:
Constant Field Values

VALIDATOR_FACTORY_KEY

public static final String VALIDATOR_FACTORY_KEY
The key in the ServletContext where the Bean Validation Factory can be found. In a managed Java EE 6 environment, the container initializes the ValidatorFactory and stores it in the ServletContext under this key. If not present, the manually instantiated ValidatorFactory is stored in the ServletContext under this key for caching purposes.

See Also:
Constant Field Values

VALIDATION_GROUPS_DELIMITER

public static final String VALIDATION_GROUPS_DELIMITER
This is used as a separator so multiple validation groups can be specified in one String.

See Also:
Constant Field Values

EMPTY_VALIDATION_GROUPS_PATTERN

public static final String EMPTY_VALIDATION_GROUPS_PATTERN
This regular expression is used to match for empty validation groups. Currently, a string containing only whitespace is classified as empty.

See Also:
Constant Field Values
Constructor Detail

BeanValidator

public BeanValidator()
Method Detail

validate

public void validate(FacesContext context,
                     UIComponent component,
                     Object value)
              throws ValidatorException

Specified by:
validate in interface Validator
Throws:
ValidatorException

saveState

public Object saveState(FacesContext context)

Specified by:
saveState in interface StateHolder

restoreState

public void restoreState(FacesContext context,
                         Object state)

Specified by:
restoreState in interface StateHolder

getValidationGroups

@JSFProperty
public String getValidationGroups()
Get the Bean Validation validation groups.

Returns:
The validation groups String.

setValidationGroups

public void setValidationGroups(String validationGroups)
Set the Bean Validation validation groups.

Parameters:
validationGroups - The validation groups String, separated by VALIDATION_GROUPS_DELIMITER.

isTransient

public boolean isTransient()

Specified by:
isTransient in interface StateHolder

setTransient

public void setTransient(boolean isTransient)

Specified by:
setTransient in interface StateHolder

clearInitialState

public void clearInitialState()

Specified by:
clearInitialState in interface PartialStateHolder

initialStateMarked

public boolean initialStateMarked()

Specified by:
initialStateMarked in interface PartialStateHolder

markInitialState

public void markInitialState()

Specified by:
markInitialState in interface PartialStateHolder


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.