public class GrailsDomainClassValidator extends java.lang.Object implements CascadingValidator, GrailsApplicationAware
| Modifier and Type | Field and Description |
|---|---|
protected GrailsDomainClass |
domainClass |
protected GrailsApplication |
grailsApplication |
protected org.springframework.context.MessageSource |
messageSource |
protected java.lang.Class<?> |
targetClass |
| Constructor and Description |
|---|
GrailsDomainClassValidator() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cascadeToAssociativeProperty(org.springframework.validation.Errors errors,
org.springframework.beans.BeanWrapper bean,
GrailsDomainClassProperty persistentProperty)
Cascades validation onto an associative property maybe a one-to-many, one-to-one or many-to-one relationship.
|
protected void |
cascadeValidationToMany(org.springframework.validation.Errors errors,
org.springframework.beans.BeanWrapper bean,
GrailsDomainClassProperty persistentProperty,
java.lang.String propertyName)
Cascades validation to a one-to-many type relationship.
|
protected void |
cascadeValidationToOne(org.springframework.validation.Errors errors,
org.springframework.beans.BeanWrapper bean,
java.lang.Object associatedObject,
GrailsDomainClassProperty persistentProperty,
java.lang.String propertyName,
java.lang.Object indexOrKey)
Cascades validation to a one-to-one or many-to-one property.
|
protected GrailsDomainClass |
getAssociatedDomainClassFromApplication(java.lang.Object associatedObject) |
GrailsDomainClass |
getDomainClass() |
protected void |
postValidate(java.lang.Object obj,
org.springframework.validation.Errors errors)
Subclasses can overrite to provide custom handling of the errors object post validation.
|
void |
setDomainClass(GrailsDomainClass domainClass) |
void |
setGrailsApplication(GrailsApplication grailsApplication)
This method is called by the
ApplicationContext that
loads the Grails application. |
void |
setMessageSource(org.springframework.context.MessageSource messageSource) |
boolean |
supports(java.lang.Class clazz) |
void |
validate(java.lang.Object obj,
org.springframework.validation.Errors errors) |
void |
validate(java.lang.Object obj,
org.springframework.validation.Errors errors,
boolean cascade)
An extended version of the validate(errors,obj) method that takes an additional argument specifying whether
the Validator should cascade into associations or not.
|
protected java.lang.Class<?> targetClass
protected GrailsDomainClass domainClass
protected org.springframework.context.MessageSource messageSource
protected GrailsApplication grailsApplication
public boolean supports(java.lang.Class clazz)
supports in interface org.springframework.validation.Validatorpublic void validate(java.lang.Object obj,
org.springframework.validation.Errors errors,
boolean cascade)
CascadingValidatorvalidate in interface CascadingValidatorobj - The Object to validateerrors - The Spring Errors instancecascade - True if validation should cascade into associationsCascadingValidator.validate(Object, org.springframework.validation.Errors, boolean)protected void postValidate(java.lang.Object obj,
org.springframework.validation.Errors errors)
obj - The object to validateerrors - The Errors objectpublic void validate(java.lang.Object obj,
org.springframework.validation.Errors errors)
validate in interface org.springframework.validation.ValidatorValidator.validate(Object, org.springframework.validation.Errors)protected void cascadeToAssociativeProperty(org.springframework.validation.Errors errors,
org.springframework.beans.BeanWrapper bean,
GrailsDomainClassProperty persistentProperty)
errors - The Errors instnacebean - The original beanpersistentProperty - The associative propertyprotected void cascadeValidationToMany(org.springframework.validation.Errors errors,
org.springframework.beans.BeanWrapper bean,
GrailsDomainClassProperty persistentProperty,
java.lang.String propertyName)
errors - The Errors instancebean - The original BeanWrapperpersistentProperty - An association whose isOneToMeny() method returns truepropertyName - The name of the propertyprotected void cascadeValidationToOne(org.springframework.validation.Errors errors,
org.springframework.beans.BeanWrapper bean,
java.lang.Object associatedObject,
GrailsDomainClassProperty persistentProperty,
java.lang.String propertyName,
java.lang.Object indexOrKey)
errors - The Errors instancebean - The original BeanWrapperassociatedObject - The associated object's current valuepersistentProperty - The GrailsDomainClassProperty instancepropertyName - The name of the propertyindexOrKey - protected GrailsDomainClass getAssociatedDomainClassFromApplication(java.lang.Object associatedObject)
public void setDomainClass(GrailsDomainClass domainClass)
domainClass - The domainClass to set.public GrailsDomainClass getDomainClass()
public void setMessageSource(org.springframework.context.MessageSource messageSource)
messageSource - The messageSource to set.public void setGrailsApplication(GrailsApplication grailsApplication)
GrailsApplicationAwareThis method is called by the ApplicationContext that
loads the Grails application. The GrailsApplication instance that represents
the loaded Grails application is injected.
setGrailsApplication in interface GrailsApplicationAwaregrailsApplication - the GrailsApplication object that represents this Grails application