Hi all,
I'm wondering if anyone has a workaround or proven solution to the following problem.
I am using Spring Webflow 2.0.9 and need to perform dynamic list binding.
From the research I have initially carried out it seems that more people have raised JIRA bugs for this rather than aimed to solve it.
However I think we can be this problem.
Current I have a sample model class like so:
Then within Web flow this can be reference like so:Code:public class MyModelClass { private List<ComplexObject> complexObjects = null; // Gets and Sets etc etc } public class ComplexObject { private String nameOfObject = null; private String description = null; // Gets and Sets etc etc }
Then my view-state is defined like so:Code:<var name="myModel" class="my.package.MyModelClass" />
And finally the JSP code for the fields:Code:<view-state id="someId" view="myTemplateView" model="myModel"> <binder> <binding property="complexObjects[0].nameOfObject" /> <binding property="complexObjects[0].description" /> </binder> </view>
Notice I refer to complexObject[0] as the reference to my binding. However the user can specify any number of complexObjects. So I either add hundreds (I'm exaggerating of course) binding properties to cover all the user may wish to do....or come up with a better solution.Code:<c:forEach items="${someCollection}" varStatus="loop"> <form:input path="complexObjects[${loop.index}].nameOfObject" /> <form:input path="complexObjects[${loop.index}].description" /> </c:forEach>
So far I have tried changing my list of complexObjects to an AutoPopulatingList like so:
And then change the binding property like so:Code:public class MyModelClass { private AutoPopulatingList<ComplexObject> complexObjects = null; public MyModelClass() { this.complexObjects = new AutoPopulatingList<ComplexObject>(ComplexObject.class); } // Gets and Sets etc etc }
This works for displaying the form however when the form is submitted the fields are not submitted along with the form.Code:<binding property="complexObjects" />
Does anyone know any proven work arounds for this?


Reply With Quote
