org.codehaus.groovy.grails.orm.hibernate.validation
Class HibernateDomainClassValidator

java.lang.Object
  extended by org.codehaus.groovy.grails.validation.GrailsDomainClassValidator
      extended by org.codehaus.groovy.grails.orm.hibernate.validation.HibernateDomainClassValidator
All Implemented Interfaces:
GrailsApplicationAware, CascadingValidator, ApplicationContextAware, Validator

public class HibernateDomainClassValidator
extends GrailsDomainClassValidator
implements ApplicationContextAware

A validator that first checks if the Hibernate PersistentCollection instance has been initialised before bothering to cascade

Since:
0.5

Created: Apr 13, 2007 Time: 6:32:08 PM

Author:
Graeme Rocher

Field Summary
 
Fields inherited from class org.codehaus.groovy.grails.validation.GrailsDomainClassValidator
domainClass, grailsApplication, messageSource, targetClass
 
Constructor Summary
HibernateDomainClassValidator()
           
 
Method Summary
protected  void cascadeValidationToMany(Errors errors, BeanWrapper bean, GrailsDomainClassProperty persistentProperty, String propertyName)
          Overrides the default behaviour and first checks if a PersistentCollection instance has been initialised using the wasInitialised() method before cascading
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)
           
protected  void postValidate(Object obj, Errors errors)
          Subclasses can overrite to provide custom handling of the errors object post validation
 void setApplicationContext(ApplicationContext applicationContext)
           
 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 org.codehaus.groovy.grails.validation.GrailsDomainClassValidator
cascadeToAssociativeProperty, getDomainClass, setDomainClass, setGrailsApplication, setMessageSource, supports, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateDomainClassValidator

public HibernateDomainClassValidator()
Method Detail

getAssociatedDomainClassFromApplication

protected GrailsDomainClass getAssociatedDomainClassFromApplication(Object associatedObject)
Overrides:
getAssociatedDomainClassFromApplication in class GrailsDomainClassValidator

validate

public void validate(Object obj,
                     Errors errors,
                     boolean cascade)
Description copied from interface: CascadingValidator
An extended version of the validate(errors,obj) method that takes an additional argument specifying whether the Validator should cascade into associations or not

Specified by:
validate in interface CascadingValidator
Overrides:
validate in class GrailsDomainClassValidator
Parameters:
obj - The Object to validate
errors - The Spring Errors instance
cascade - True if validation should cascade into associations
See Also:
CascadingValidator.validate(Object, org.springframework.validation.Errors, boolean)

cascadeValidationToMany

protected void cascadeValidationToMany(Errors errors,
                                       BeanWrapper bean,
                                       GrailsDomainClassProperty persistentProperty,
                                       String propertyName)
Overrides the default behaviour and first checks if a PersistentCollection instance has been initialised using the wasInitialised() method before cascading

Overrides:
cascadeValidationToMany in class GrailsDomainClassValidator
Parameters:
errors - The Spring Errors instance
bean - The BeanWrapper for the bean
persistentProperty - The GrailsDomainClassProperty instance
propertyName - The name of the property
See Also:
PersistentCollection.wasInitialized()

cascadeValidationToOne

protected void cascadeValidationToOne(Errors errors,
                                      BeanWrapper bean,
                                      Object associatedObject,
                                      GrailsDomainClassProperty persistentProperty,
                                      String propertyName)
Description copied from class: GrailsDomainClassValidator
Cascades validation to a one-to-one or many-to-one property

Overrides:
cascadeValidationToOne in class GrailsDomainClassValidator
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

postValidate

protected void postValidate(Object obj,
                            Errors errors)
Description copied from class: GrailsDomainClassValidator
Subclasses can overrite to provide custom handling of the errors object post validation

Overrides:
postValidate in class GrailsDomainClassValidator
Parameters:
obj - The object to validate
errors - The Errors object

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException


Copyright (c) 2005-2009 The Grails project