What I wonder is if there\'s a easier/better way to handle dynamic forms (adding form items to the dom via js) when using SpringMVC and Spring forms?
Imaging having
I've found that also decorating with a GrowthList is necessary to avoid some errors when adding/setting items in JSP. (Also created a custom SpringList impl. that basically does the double decoration.)
lineItems = GrowthList.decorate(ListUtils.lazyList(new ArrayList(), FactoryUtils.instantiateFactory(LineItem.class)));
I agree. The problem is certainly removing items.
What you can do is use the spring marker syntax in the html. So if you remove an item (at index 2 for example) from the list using javascript, you would then mark that index with:
Then when the form is submitted spring will see the marker and put in an empty item (based on the lazylist factory) for lineItems2 instead of ignoring it.