So I have set up a wizard interface with spring web flow that gradually populates a single form object/model. It works fine for the first few steps that have to populate single String or primitive properties and a String array (from a checkbox interface).
Then I have a List<String> property. It renders properly as multiple textboxes with correct initialized values. But when I edit the textboxes on the browser and submit, the values do not take effect on the form bean. It still has the initial values.
Below is the detailed set-up:
Web flow on-start which creates the bean:
Here are the relevant parts of my form bean:Code:<on-start> <evaluate expression="new mypackage.MyFormBean()" result="flowScope.myFormBean" /> </on-start>
I have a series of view-states in my web flow with simple string or number field bindings set-up that are initialized, displayed and saved without issues to the form.Code:public class MyFormBean implements Serializable { ... private List<SlotBean> slots; ... public List<SlotBean> getSlots() { return slots; } public void setSlots(List<SlotBean> slots) { this.slots= slots; } ... } public class SlotBean { ... private int quantity; ... public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity= quantity; } ... }
This view-state generates any number of SlotBean objects then initializes quantity with 2. These are set to the slots property.
Here is the jsp fragment. All it does is render a bunch of textboxes. There's also a next button:Code:<view-state id="generate-criteria" model="disciplineCatalogue"> ... <transition on="next" to="slots-grid"> <evaluate expression="myService.generateSlots(myFormBean)"/> </transition> ... </view-state>
The above code displays correctly with the initial values (2). It generates multiple textboxes like below:Code:<form:form id="slotsGrid" modelAttribute="myFormBean" action="${flowExecutionUrl}"> ... <c:forEach var="slot" items="${myFormBean.slots}" varStatus="idx"> <form:input path="slots[${idx.index}].quantity" /> </c:forEach> ... <button type="submit" id="next" name="_eventId_next">Next</button> ... </form:form>
So when this page is on the browser, I change the values of the quantity textboxes to different values and click the "next" button. On my browser's network debugger, I see that the form values are sent to the server:Code:<input id="slots0.quantity" name="slots[0].quantity" type="text" value="2"/>
Here is the relevant web flow entry for the next button.Code:slots[0].quantity:3 slots[1].quantity:1 slots[2].quantity:2
So I put a break point on the myService.create(myFormBean) method and it shows that all the quantity fields are still set to the original "2". The new values didn't bind to myFormBean.slots.Code:<view-state id="slots-grid" model="myFormBean"> <binder> ... <binding property="slots" /> </binder> ... <transition on="next" to="finished"> <evaluate expression="myService.create(myFormBean)"/> </transition> ... </view-state>
Is there anything you can see in my set-up that looks wrong?
Thanks for any time you can put into this
Spring Framework 3.1.1
Spring-Webflow 2.3.1
Tomcat 6.0.18
Eclipse Indigo
cross-posted yesterday in:
http://stackoverflow.com/questions/1...on-form-submit


Reply With Quote