Question

My controller is something like this:

class UserController{
    def register= {UserCommand command ->
        println params
        println command.dump()
        // do something ..........

    }
}
class UserCommand {
    String username
    static constraints = {
        username nullable: false
    }

}

My gsp file has a form with an input(text) named : "command.username", after the form is submitted, I can see the params print out, but my command object is empty, I thought command objects are suppose to automatically bind it self with the params data when you pass them over, is there something that I missed?

Thanks

Was it helpful?

Solution

Binding to the command object will match keys from the params with properties on the command object, the same way binding from params to a domain object works. The property in the form should be named username, not command.username. command.username would try to bind to the username property on a command object on the UserCommand.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top