When attempting to add a custom error message to a command object (non-domain object), I was trying to do this in the following way:
commandObject.errors.reject(null, "Some error msg")
However, when I go to execute the application, I received the following error:
No such property: errorsIt turns out, that the errors property of a command object is not always created.
The Solution
To have grails automatically create the errors object, the command objects must be annotated as "@Validateable"
and in the Config.groovy file add the following line:
grails.validateable.packages=['package.name.containing.command.object']
References:
http://grails.1312388.n4.nabble.com/Possible-problem-with-Controller-Commands-and-errors-td2257062.html
http://www.grails.org/doc/1.3.7/guide/7.%20Validation.html#7.5%20Validation%20Non%20Domain%20and%20Command%20Object%20Classes
No comments:
Post a Comment