com.opensymphony.xwork.validator.validators
Class CollectionFieldValidator

java.lang.Object
  extended by com.opensymphony.xwork.validator.validators.ValidatorSupport
      extended by com.opensymphony.xwork.validator.validators.FieldValidatorSupport
          extended by 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.

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

Nested Class Summary
protected  class CollectionFieldValidator.CloneableIterator
          A cloneable iterator, when the iterator is cloned, its state is preserved, eg.
protected  class CollectionFieldValidator.PropertySpliter
          Splits up the properties supplied, eg.
 
Field Summary
 
Fields inherited from class com.opensymphony.xwork.validator.validators.ValidatorSupport
defaultMessage, log, messageKey
 
Constructor Summary
CollectionFieldValidator()
           
 
Method Summary
 String getProperty()
           
 Map getValidatorParams()
           
 String getValidatorRef()
           
protected  void populateValue(Object obj, CollectionFieldValidator.CloneableIterator iterator, List result, String overallPropertyName)
          Populate result with a list of property name, eg.
 void setProperty(String collection)
           
 void setValidatorParams(Map validatorParams)
           
 void setValidatorRef(String validatorRef)
           
 void validate(Object object)
          Validate the object.
 
Methods inherited from class com.opensymphony.xwork.validator.validators.FieldValidatorSupport
getFieldName, getValidatorType, setFieldName, setValidatorType
 
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
 
Methods inherited from interface com.opensymphony.xwork.validator.Validator
getDefaultMessage, getMessage, getMessageKey, getValidatorContext, setDefaultMessage, setMessageKey, setValidatorContext
 

Constructor Detail

CollectionFieldValidator

public CollectionFieldValidator()
Method Detail

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 :-

Parameters:
obj -
iterator -
result -
overallPropertyName -
Throws:
ognl.OgnlException
CloneNotSupportedException

XWork Project Page