com.opensymphony.xwork.validator.validators
Class CollectionFieldValidator
java.lang.Object
com.opensymphony.xwork.validator.validators.ValidatorSupport
com.opensymphony.xwork.validator.validators.FieldValidatorSupport
com.opensymphony.xwork.validator.validators.CollectionFieldValidator
- All Implemented Interfaces:
- FieldValidator, ShortCircuitableValidator, Validator
public class CollectionFieldValidator
- extends FieldValidatorSupport
Validate a property available in the object of a collection.
- property - the full property name that this validator should validate.
eg. if "persons" is a collection of Persons object with a property
called name the property would be "persons.name"
- validatorRef - validator name of an existing validator (could not be "collection" validator)
eg. required, requiredstring, int etc.
- validatorParams - the parameters to be passed into the validator referenced
by the "validatorParams" attribute above.
public class MyAction extends ActionSupport {
private List persons = new ArrayList();
....
public List getPersons() { return this.persons; }
public void setPersons(List persons) { this.persons = persons; }
}
public class Person {
private String name;
private Integer age;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Integer getAge() { return age; }
public void setAge(Integer age) { this.age = age; }
}
persons.name
requiredstring
Must be String
true
persons.age
Must be filled in
persons.age
int
Needs to be an integer
- Version:
- $Date$ $Id$
- Author:
- tmjee
| Methods inherited from class com.opensymphony.xwork.validator.validators.ValidatorSupport |
addActionError, addFieldError, conditionalParse, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getParse, getValidatorContext, isShortCircuit, setDefaultMessage, setMessageKey, setParse, setShortCircuit, setValidatorContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CollectionFieldValidator
public CollectionFieldValidator()
getProperty
public String getProperty()
setProperty
public void setProperty(String collection)
getValidatorRef
public String getValidatorRef()
setValidatorRef
public void setValidatorRef(String validatorRef)
setValidatorParams
public void setValidatorParams(Map validatorParams)
getValidatorParams
public Map getValidatorParams()
validate
public void validate(Object object)
throws ValidationException
- Validate the
object.
- Throws:
ValidationException- See Also:
Validator#validate(Object)}
populateValue
protected void populateValue(Object obj,
CollectionFieldValidator.CloneableIterator iterator,
List result,
String overallPropertyName)
throws ognl.OgnlException,
CloneNotSupportedException
- Populate
result with a list of property name, eg.
if we have a list of Person object with a property called "name". If we have
2 persons in the list the result would be :-
- persons[0].name
- persons[1].name
- Parameters:
obj - iterator - result - overallPropertyName -
- Throws:
ognl.OgnlException
CloneNotSupportedException