|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.grails.validation.GrailsDomainClassValidator
public class GrailsDomainClassValidator
A specialised Spring validator that validates a domain class instance using the constraints defined in the static constraints closure.
Field Summary | |
---|---|
protected GrailsDomainClass |
domainClass
|
protected GrailsApplication |
grailsApplication
|
protected MessageSource |
messageSource
|
protected Class |
targetClass
|
Constructor Summary | |
---|---|
GrailsDomainClassValidator()
|
Method Summary | |
---|---|
protected void |
cascadeToAssociativeProperty(Errors errors,
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(Errors errors,
BeanWrapper bean,
GrailsDomainClassProperty persistentProperty,
String propertyName)
Cascades validation to a one-to-many type relationship. |
protected void |
cascadeValidationToOne(Errors errors,
BeanWrapper bean,
Object associatedObject,
GrailsDomainClassProperty persistentProperty,
String propertyName)
Cascades validation to a one-to-one or many-to-one property |
protected GrailsDomainClass |
getAssociatedDomainClassFromApplication(Object associatedObject)
|
GrailsDomainClass |
getDomainClass()
|
protected void |
postValidate(Object obj,
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(MessageSource messageSource)
|
boolean |
supports(Class clazz)
|
void |
validate(Object obj,
Errors errors)
|
void |
validate(Object obj,
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Class targetClass
protected GrailsDomainClass domainClass
protected MessageSource messageSource
protected GrailsApplication grailsApplication
Constructor Detail |
---|
public GrailsDomainClassValidator()
Method Detail |
---|
public boolean supports(Class clazz)
supports
in interface Validator
public void setDomainClass(GrailsDomainClass domainClass)
domainClass
- The domainClass to set.public GrailsDomainClass getDomainClass()
public void setMessageSource(MessageSource messageSource)
messageSource
- The messageSource to set.public void validate(Object obj, Errors errors, boolean cascade)
CascadingValidator
validate
in interface CascadingValidator
obj
- 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(Object obj, Errors errors)
obj
- The object to validateerrors
- The Errors objectpublic void validate(Object obj, Errors errors)
validate
in interface Validator
Validator.validate(Object, org.springframework.validation.Errors)
protected void cascadeToAssociativeProperty(Errors errors, BeanWrapper bean, GrailsDomainClassProperty persistentProperty)
errors
- The Errors instnacebean
- The original beanpersistentProperty
- The associative propertyprotected void cascadeValidationToMany(Errors errors, BeanWrapper bean, GrailsDomainClassProperty persistentProperty, String propertyName)
errors
- The Errors instancebean
- The original BeanWrapperpersistentProperty
- An association whose isOneToMeny() method returns truepropertyName
- The name of the propertyprotected void cascadeValidationToOne(Errors errors, BeanWrapper bean, Object associatedObject, GrailsDomainClassProperty persistentProperty, String propertyName)
errors
- The Errors instancebean
- The original BeanWrapperassociatedObject
- The associated object's current valuepersistentProperty
- The GrailsDomainClassProperty instancepropertyName
- The name of the propertyprotected GrailsDomainClass getAssociatedDomainClassFromApplication(Object associatedObject)
public void setGrailsApplication(GrailsApplication grailsApplication)
GrailsApplicationAware
This 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 GrailsApplicationAware
grailsApplication
- the GrailsApplication
object that represents this Grails application
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |