title: better way for dynamic forms with Spring?
body: <p>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?</p>
  
  <p>Imaging having an Invoice object that have many LineItems.</p>
  
  <pre><code>public class Invocie {
      private List LineItems;
  
      public Invoice() {
          lineItems = ListUtils.lazyList(new ArrayList&lt;LineItem&gt;(), FactoryUtils.instantiateFactory(LineItem.class));
      }
  }
  </code></pre>
  
  <p>To show the items belonging to an Invoice I currently use</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;forEach items="${invoice.lineItems}" varStatus="i"&gt;
    &lt;form:input path="lineItems[${i.index}].productName" /&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>To add LineItems I have some js that calculates the new index and adds that to the DOM. When deleting a LineItem i currently have to renumber all the indexes and that's the part I'd like to avoid, is it possible?</p>