We had a similar problem with the attached data of the message to the list inside the command. Our approach to work was to determine the default value for the elements of the collection:
class MyCommand { List<MyClass> items= [].withLazyDefault { new MyClass() } }
After that, the mail data was correctly bound to the list. I think the reason is that Groovy ignores the generic type parameter in the list and does not know which object to instantiate at runtime.
I'm not sure if this works in your case, but it might be worth a try
Update:
I used this a few minutes ago:
public static class MyCommand { String foo List<Bar> bars public String toString() { return "foo: " + foo + ", bars: " + bars } } public static class Bar { String baz }
:
def test() { println new MyCommand(request.JSON) }
I wrote json using jquery:
$.ajax({ type: "POST", url: '...', data: JSON.stringify({ 'foo': '12345', bars: [ {baz: '1'}, {baz: '2'} ] }), contentType : 'application/json', });
Controller output:
foo: 12345, bars: [[baz:1], [baz:2]]
So this works: o
source share