New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remote validation not working with command objects #17
Comments
Hi Pascal, Thanks for report the issue. Could you clone the project, apply the fix and send me pull request. Thank you |
OK! I did. Made the change ready to push them. However I have a question. in validate of JQueryRemoveValidationController param doesn't have all the fields value of the form. Therefore the binding doesn't happen which mean I cannot have a custom validator that check the value of another field. (ie password check). Where should I look to add this? |
@pdemilly I just wanted to offer a suggestion, even though this thread is 3 months old and it is likely that you have already addressed the issue of not having a command object that is fully populated.
As the variable name of the form is always myForm you may serialize the entire form and then use the values from the params.serializedData in the remote validation controller. This is somewhat of an un-elegant solution, but it gets the values up to the validation controller and we use them as necessary to bind to the Validateable class currently under remote validation. |
…/command object in JQueryRemoteValidationController.
I have now pushed a fix for this problem (pull request #26) which is nearly identical to what Pascal proposed. |
When using command objects a few things don't work correctly.
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
and add this after initiating validatableInstance in the method validate() around line 41
applicationContext.autowireCapableBeanFactory.autowireBeanProperties(validatableInstance,AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false)
in same method validate() around line 57 replace
by
if(validatableInstance.metaClass.respondsTo(validatableInstance, "isAttached") && validatableInstance.isAttached())
validatableInstance.discard()
Hope that helps
Regards
Pascal
The text was updated successfully, but these errors were encountered: