'Grails 3: Binding multiple command objects via POST

I have a controller with a method that I want to bind multiple command objects too. When I call the method via GET, it works great and both objects get bound. The issue is if I call the method via POST, only the first command object gets bound and the second one is completely ignored.

Simple example:

def register(MembershipCommand cmd1, RegisterCommand cmd2) {
        println(cmd1.email);
        println(cmd2.pass);
        respond([:]);
}

If I call /register?email=test&pass=test then cmd1 and cmd2 get populated

If I call /register with POST data {email:test,pass:test}, cmd1 gets populated and cmd2.pass is null.

Is there a way to make this data binding work using POST? I can't really use GET because file uploads are involved and plus the forms are fairly large.

I know that another option would be to just split the method into 2, 1 for each object and have my form submit to each separately but I want to avoid that if I can.

Any ideas?



Solution 1:[1]

The solution to get POST working was to restructure my form data into an object style format.

So instead of {email:test,pass:test}

I would have {cmd1:{email:test}, cmd2:{pass:test}}

Solution 2:[2]

For Grails 3.3.X having multiple command objects doesn't seem to be supported.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Raymond Holguin
Solution 2 David Ha