Groovy Documentation

org.codehaus.groovy.grails.validation
[Java] Class GrailsDomainClassValidator

java.lang.Object
  org.codehaus.groovy.grails.validation.GrailsDomainClassValidator
All Implemented Interfaces:
org.springframework.validation.Validator, CascadingValidator, GrailsApplicationAware

public class GrailsDomainClassValidator
extends java.lang.Object

A specialised Spring validator that validates a domain class instance using the constraints defined in the static constraints closure.

Authors:
Graeme Rocher
Since:
0.1


Field Summary
protected GrailsDomainClass domainClass

protected GrailsApplication grailsApplication

protected org.springframework.context.MessageSource messageSource

protected java.lang.Class targetClass

 
Method Summary
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)

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)

@param domainClass The domainClass to set.

void setGrailsApplication(GrailsApplication grailsApplication)

void setMessageSource(org.springframework.context.MessageSource messageSource)

@param messageSource The messageSource to set.

boolean supports(java.lang.Class clazz)

void validate(java.lang.Object obj, org.springframework.validation.Errors errors, boolean cascade)

@see org.codehaus.groovy.grails.validation.CascadingValidator#validate(Object, org.springframework.validation.Errors, boolean)

void validate(java.lang.Object obj, org.springframework.validation.Errors errors)

@see org.springframework.validation.Validator#validate(Object, org.springframework.validation.Errors)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

domainClass

protected GrailsDomainClass domainClass


grailsApplication

protected GrailsApplication grailsApplication


messageSource

protected org.springframework.context.MessageSource messageSource


targetClass

protected java.lang.Class targetClass


 
Method Detail

cascadeToAssociativeProperty

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.
Parameters:
errors - The Errors instnace
bean - The original bean
persistentProperty - The associative property


cascadeValidationToMany

@SuppressWarnings("rawtypes")
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. Normally a collection such as a List or Set each element in the association will also be validated.
Parameters:
errors - The Errors instance
bean - The original BeanWrapper
persistentProperty - An association whose isOneToMeny() method returns true
propertyName - The name of the property


cascadeValidationToOne

@SuppressWarnings("rawtypes")
protected void cascadeValidationToOne(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, java.lang.Object associatedObject, GrailsDomainClassProperty persistentProperty, java.lang.String propertyName)
Cascades validation to a one-to-one or many-to-one property.
Parameters:
errors - The Errors instance
bean - The original BeanWrapper
associatedObject - The associated object's current value
persistentProperty - The GrailsDomainClassProperty instance
propertyName - The name of the property


getAssociatedDomainClassFromApplication

protected GrailsDomainClass getAssociatedDomainClassFromApplication(java.lang.Object associatedObject)


getDomainClass

public GrailsDomainClass getDomainClass()


postValidate

@SuppressWarnings("unused")
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.
Parameters:
obj - The object to validate
errors - The Errors object


setDomainClass

public void setDomainClass(GrailsDomainClass domainClass)
Parameters:
domainClass - The domainClass to set.


setGrailsApplication

public void setGrailsApplication(GrailsApplication grailsApplication)


setMessageSource

public void setMessageSource(org.springframework.context.MessageSource messageSource)
Parameters:
messageSource - The messageSource to set.


supports

@SuppressWarnings("rawtypes")
public boolean supports(java.lang.Class clazz)


validate

@SuppressWarnings({ "unchecked", "rawtypes" })
public void validate(java.lang.Object obj, org.springframework.validation.Errors errors, boolean cascade)
See Also:
CascadingValidator.validate


validate

public void validate(java.lang.Object obj, org.springframework.validation.Errors errors)
See Also:
org.springframework.validation.Validator#validate(Object, org.springframework.validation.Errors)


 

Groovy Documentation