public class VisitorFieldValidator extends FieldValidatorSupport
<validators> <!-- Plain Validator Syntax --> <validator type="visitor"> <param name="fieldName">user</param> <param name="context">myContext</param> <param name="appendPrefix">true</param> </validator> <!-- Field Validator Syntax --> <field name="user"> <field-validator type="visitor"> <param name="context">myContext</param> <param name="appendPrefix">true</param> </field-validator> </field> </validators>
In the example above, if the acion's getUser() method return User object, XWork will look for User-myContext-validation.xml for the validators. Since appednPrefix is true, every field name will be prefixed with 'user' such that if the actual field name for 'name' is 'user.name'
Modifier and Type | Class and Description |
---|---|
static class |
VisitorFieldValidator.AppendingValidatorContext |
defaultMessage, log, messageKey, stack
Constructor and Description |
---|
VisitorFieldValidator() |
Modifier and Type | Method and Description |
---|---|
String |
getContext() |
boolean |
isAppendPrefix()
Flags whether the field name of this field validator should be prepended to the field name of
the visited field to determine the full field name when an error occurs.
|
void |
setActionValidatorManager(ActionValidatorManager mgr) |
void |
setAppendPrefix(boolean appendPrefix)
Sets whether the field name of this field validator should be prepended to the field name of
the visited field to determine the full field name when an error occurs.
|
void |
setContext(String context) |
void |
validate(Object object)
The validation implementation must guarantee that setValidatorContext will
be called with a non-null ValidatorContext before validate is called.
|
getFieldName, getValidatorType, setFieldName, setValidatorType
addActionError, addFieldError, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setValidatorContext, setValueStack
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack
public void setActionValidatorManager(ActionValidatorManager mgr)
public void setAppendPrefix(boolean appendPrefix)
public boolean isAppendPrefix()
public void setContext(String context)
public String getContext()
public void validate(Object object) throws ValidationException
Validator
object
- the object to be validated.ValidationException
- is thrown if there is validation error(s).Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.