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?