WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

remote validation not working with command objects #17

@pdemilly

Description

@pdemilly

When using command objects a few things don't work correctly.

  1. auto wiring.

when a custom validator needs to access a service defined in the command object (same might be for domain object), the service instance variable has not been injected before calling the custom validator.

in JQueryRemoteValidatorController.groovy

                        import org.springframework.beans.factory.config.AutowireCapableBeanFactory

and add this after initiating validatableInstance in the method validate() around line 41
applicationContext.autowireCapableBeanFactory.autowireBeanProperties(validatableInstance,AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false)

  1. command objects don't respond to isAttached

in same method validate() around line 57 replace

          if(validatableInstance.isAttached()) validatableInstance.discard()

by
if(validatableInstance.metaClass.respondsTo(validatableInstance, "isAttached") && validatableInstance.isAttached())
validatableInstance.discard()

Hope that helps

Regards

Pascal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions