When a CommandObject is added directly to a Controller.groovy file, and the CommandObject is not marked with 'implements Validateable'
overriding defaultNullable() does not work.
Steps to Reproduce
- Create a grails app.
- Generate a controller.
- Create a command Object in the Controller file with 'static boolean defaultNullable() {true}', relying on the fact that Command Objects are Validateable by default in controllers, and do not manually add the "implements Validateable" clause.
- Create a controller action that expects the command Object as a parameter.
- Call that controller action without any arguments.
- Examine the command object.
Expected Behaviour
The CommandObject should validate and not have any errors.
According to section 8.1.9 of the manual
If the command object is defined in the same source file as the controller that is using it, Grails will automatically make it Validateable. It is not required that command object classes be validateable.
Validate is being called, but the validate method is not respecting the defaultNullable() override.
Actual Behaviour
The CommandObject has a validation error for every property.
Environment Information
- Operating System: Windows
- Grails Version: 3.1.9
- JDK Version: 1.7_80
- Container Version (If Applicable): grails run-app
Example Application
This example application exposes one controller with two actions.
https://github.com/tircnf/grails-command-object
http://localhost:8080/command/command1
and
http://localhost:8080/command/command2
command1 uses a patientCommand object that does not 'implement Validateable' and throws validation errors.
command2 uses a command object that does implement it.
Both command objects try to override the static defaultNullable method.