Class ValidatorSupport
java.lang.Object
org.apache.struts2.validator.validators.ValidatorSupport
- All Implemented Interfaces:
- ShortCircuitableValidator,- Validator
- Direct Known Subclasses:
- ExpressionValidator,- FieldValidatorSupport
public abstract class ValidatorSupport
extends Object
implements Validator, ShortCircuitableValidator
Abstract implementation of the Validator interface suitable for subclassing.
- Author:
- Jason Carreira, tm_jee, Martin Gilday
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Stringstatic final Stringprotected Stringprotected ValueStackprotected TextProviderFactory
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddActionError(Object object) protected voidaddFieldError(String propertyName, Object object) Gets the default message used for validation failuresprotected ObjectgetFieldValue(String name, Object object) Return the field value namednamefromobject,objectshould have the appropriate getter/setter.getMessage(Object object) Gets the validation failure message for the given objectGets the resource bundle key used for lookup of validation failure messageString[]Gets the message parameters to be used when parsing i18n messagesGets the validation context usedGets the validator type used (see class javadoc).booleanGets whether this field validator should short circuit the validator queue it's in if validation fails.protected ObjectParseexpressionpassed in against value stack.voidsetDefaultMessage(String message) Sets the default message to use for validation failurevoidsetMessageKey(String key) Sets a resource bundle key to be used for lookup of validation failure messagevoidsetMessageParameters(String[] messageParameters) Sets the message parameters to be used when parsing i18n messagesvoidsetShortCircuit(boolean shortcircuit) Sets whether this field validator should short circuit the validator queue it's in if validation fails.voidsetTextProviderFactory(TextProviderFactory textProviderFactory) voidsetValidatorContext(ValidatorContext validatorContext) This method will be called before validate with a non-null ValidatorContext.voidsetValidatorType(String type) Sets the validator type to use (see class javadoc).voidsetValueStack(ValueStack stack) Sets the value stack to use to resolve values and parameters
- 
Field Details- 
EMPTY_STRING- See Also:
 
- 
defaultMessage
- 
messageKey
- 
stack
- 
textProviderFactory
 
- 
- 
Constructor Details- 
ValidatorSupportpublic ValidatorSupport()
 
- 
- 
Method Details- 
setTextProviderFactory
- 
setValueStackDescription copied from interface:ValidatorSets the value stack to use to resolve values and parameters- Specified by:
- setValueStackin interface- Validator
- Parameters:
- stack- The value stack for the request
 
- 
setDefaultMessageDescription copied from interface:ValidatorSets the default message to use for validation failure- Specified by:
- setDefaultMessagein interface- Validator
- Parameters:
- message- the default message
 
- 
getDefaultMessageDescription copied from interface:ValidatorGets the default message used for validation failures- Specified by:
- getDefaultMessagein interface- Validator
- Returns:
- the default message
 
- 
getMessageDescription copied from interface:ValidatorGets the validation failure message for the given object- Specified by:
- getMessagein interface- Validator
- Parameters:
- object- object being validated (eg. a domain model object)
- Returns:
- the validation failure message
 
- 
setMessageKeyDescription copied from interface:ValidatorSets a resource bundle key to be used for lookup of validation failure message- Specified by:
- setMessageKeyin interface- Validator
- Parameters:
- key- the resource bundle key
 
- 
getMessageKeyDescription copied from interface:ValidatorGets the resource bundle key used for lookup of validation failure message- Specified by:
- getMessageKeyin interface- Validator
- Returns:
- the resource bundle key
 
- 
getMessageParametersDescription copied from interface:ValidatorGets the message parameters to be used when parsing i18n messages- Specified by:
- getMessageParametersin interface- Validator
- Returns:
- the message parameters
 
- 
setMessageParametersDescription copied from interface:ValidatorSets the message parameters to be used when parsing i18n messages- Specified by:
- setMessageParametersin interface- Validator
- Parameters:
- messageParameters- the message parameters
 
- 
setShortCircuitpublic void setShortCircuit(boolean shortcircuit) Description copied from interface:ShortCircuitableValidatorSets whether this field validator should short circuit the validator queue it's in if validation fails.- Specified by:
- setShortCircuitin interface- ShortCircuitableValidator
- Parameters:
- shortcircuit- true if this field validator should short circuit on failure, false otherwise
 
- 
isShortCircuitpublic boolean isShortCircuit()Description copied from interface:ShortCircuitableValidatorGets whether this field validator should short circuit the validator queue it's in if validation fails.- Specified by:
- isShortCircuitin interface- ShortCircuitableValidator
- Returns:
- true if this field validator should short circuit on failure, false otherwise
 
- 
setValidatorContextDescription copied from interface:ValidatorThis method will be called before validate with a non-null ValidatorContext.- Specified by:
- setValidatorContextin interface- Validator
- Parameters:
- validatorContext- the validation context to use.
 
- 
getValidatorContextDescription copied from interface:ValidatorGets the validation context used- Specified by:
- getValidatorContextin interface- Validator
- Returns:
- the validation context
 
- 
setValidatorTypeDescription copied from interface:ValidatorSets the validator type to use (see class javadoc).- Specified by:
- setValidatorTypein interface- Validator
- Parameters:
- type- the type to use.
 
- 
getValidatorTypeDescription copied from interface:ValidatorGets the validator type used (see class javadoc).- Specified by:
- getValidatorTypein interface- Validator
- Returns:
- the type used
 
- 
parseParseexpressionpassed in against value stack.- Parameters:
- expression- an OGNL expression
- type- type to return
- Returns:
- Object
 
- 
getFieldValueReturn the field value namednamefromobject,objectshould have the appropriate getter/setter.- Parameters:
- name- name of the field
- object- to search field name on
- Returns:
- Object as field value
- Throws:
- ValidationException- in case of validation problems
 
- 
addActionError
- 
addFieldError
 
-