I have a simple Foo class with two attributes and a form binder:
import play.data.Form; public class Foo { public static Form<Foo> form = Form.form(Foo.class); public String name; public List<Bar> bars = new ArrayList<Bar>(); }
Where is the Bar class:
public class Bar { public String prop1; public String prop2; }
When I try to execute an ajax POST request:
jsRoutes.controllers.Test.duh().ajax({ data: { name: "Test", bars: [{prop1: "first"}] } });
in the duh method, in the line:
Form<Foo> request = Foo.form.bindFromRequest();
I get an error:
[InvalidPropertyException: Invalid property] [0] [prop1] 'from beanclass [models.Foo]: the property referenced by the path of the indexed property' bars [0] [prop1] 'is neither an array, nor a list, nor a map; the returned value was [first]]
AJAX form request Form data is as follows:
name:Test bars[0][prop1]:first
Question:. How can I link a list of complex elements in a gaming environment? What else is needed for this code to work?
source share