Package jakarta.faces.validator
Class BeanValidator
- java.lang.Object
-
- jakarta.faces.validator.BeanValidator
-
- All Implemented Interfaces:
PartialStateHolder
,StateHolder
,Validator
,EventListener
@JSFValidator(name="f:validateBean", bodyContent="empty") @JSFJspProperty(name="binding", returnType="jakarta.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
-
-
Field Summary
Fields Modifier and Type Field Description 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
ENABLE_VALIDATE_WHOLE_BEAN_PARAM_NAME
Enable f:validateWholeBean use.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 Faces 2.0 specification.
-
Constructor Summary
Constructors Constructor Description BeanValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)
-
-
-
Field Detail
-
VALIDATOR_ID
public static final String VALIDATOR_ID
Converter ID, as defined by the Faces 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
-
ENABLE_VALIDATE_WHOLE_BEAN_PARAM_NAME
@JSFWebConfigParam(since="2.3", defaultValue="false", expectedValues="true, false", group="validation") public static final String ENABLE_VALIDATE_WHOLE_BEAN_PARAM_NAME
Enable f:validateWholeBean use.- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
public void validate(FacesContext context, UIComponent component, Object value)
-
saveState
public Object saveState(FacesContext context)
- Specified by:
saveState
in interfaceStateHolder
-
restoreState
public void restoreState(FacesContext context, Object state)
- Specified by:
restoreState
in interfaceStateHolder
-
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 byVALIDATION_GROUPS_DELIMITER
.
-
isTransient
public boolean isTransient()
- Specified by:
isTransient
in interfaceStateHolder
-
setTransient
public void setTransient(boolean isTransient)
- Specified by:
setTransient
in interfaceStateHolder
-
clearInitialState
public void clearInitialState()
- Specified by:
clearInitialState
in interfacePartialStateHolder
-
initialStateMarked
public boolean initialStateMarked()
- Specified by:
initialStateMarked
in interfacePartialStateHolder
-
markInitialState
public void markInitialState()
- Specified by:
markInitialState
in interfacePartialStateHolder
-
-