I'm trying to submit array with new items using spring webflow. For eaxmple if myList has size 3 and then i add 4th item then submit fails.
<c:forEach items="${myList}" var="item" varStatus="status">
<tr>
<td>
<input type="number" readonly class="form-control" value="${item.a}" name="myList[${status.index}].a"/>
</td>
<td>
<input type="number" class="form-control" value="${item.b}" name="myList[${status.index}].b"/>
</td>
<td class="text-center">
<i class="fa fa-trash delete" data-link="${flowExecutionUrl}&_eventId=deleteItem&itemId=${item.id}"></i>
</td>
</tr>
</c:forEach>
<tr>
<td>
<input type="number" readonly class="form-control" value="1234" name="myList[3].a"/>
</td>
<td>
<input type="number" class="form-control" value="5678" name="myList[3].b"/>
</td>
<td class="text-center">
<i class="fa fa-trash delete"></i>
</td>
</tr>
So how to submit such form?
because the ArrayList you are providing the databinder has a predefined fixed size and cannot accept new entries.
You need to wrap your ArrayList with an AutoPopulatingList (located in spring-core.jar) before attempting to add any new entries to the data binder in your flows.... (or simply use an AutoPopulatingList on your pojo to avoid wrapper method).
Sample conversion method:
//class definition skipped
Java Doc:
Also, please be aware of the 'autoGrowCollectionLimit' property on the initBinder. The default max value is 256 entries. This can be adjusted if you need more (or less). See
Can not post form with many (over 256) values