title: Weird problem when binding a dynamic list
body: <p><strong>INITIAL QUESTION (UPDATED BELOW)</strong></p>
  
  <p>I'm using an <code>AutoPopulatingList</code> list to instatiate an object invoking a constructor with some parameters. Something like the code below. I had used it before without any problems but I can't get it working now.</p>
  
  <pre><code>public class Tree {
      ...
      private List&lt;Node&gt; nodes = new AutoPopulatingList&lt;Node&gt;(new ElementFactory&lt;Node&gt;() {
          @Override
          public Node createElement(final int index) throws ElementInstantiationException {
               //call custom controller
               return new Node(index, ...other params);
          }       
      });
      ...
      //getters &amp; setters
  }
  </code></pre>
  
  <p>The object is mapped in a controller as a model attribute param (<code>@ModelAttribute Tree</code>). So I send in the form values like:</p>
  
  <pre><code>nodes[0].field1 = some value
  nodes[1].field2 = other value
  </code></pre>
  
  <p>But when I send these parameters spring cannot instantiate the <code>Node</code> object because it's looking for a constructor without params for <code>Node</code> object, and it throws an Exception like the following:</p>
  
  <blockquote>
    <p>org.springframework.beans.NullValueInNestedPathException: Invalid property 'nodes' of bean class [...Node]: Could not instantiate property type [...Node] to auto-grow nested property path: java.lang.InstantiationException: ...Node.()</p>
  </blockquote>
  
  <p>If I add a constructor without params to <code>Node</code> class there is no error, but when I send <code>nodes[0]</code> it is invoked <code>Node()</code> instead of using the <code>ElementFactory</code> provided.</p>
  
  <p>The weird thing is that if I do in the controller <code>treeObject.getNodes().get(0)</code>, the constructor invoked is the one with params (as it should be).</p>
  
  <p>I'm using Spring 3.0.4.RELEASE.</p>
  
  <p>Does anybody knows why can this be happening? Can this be a bug?</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have build a custom implementation of a List similar to AutoPopulatingList to check if this was a problem of AutoPopulatingList, but it happens the same behaviour.
  The implementation just overrides:</p>
  
  <pre><code>public Node get(int index) {
      //here just creates the object it it doesn't exist in the position
  }
  </code></pre>
  
  <p>So the problem is why when I do in a controller:</p>
  
  <pre><code>public String controllerMethod(
  @ModelAttribute Tree tree, BindingResult result, Model model){
       ...
  }
  </code></pre>
  
  <p>and I send nodes[0].something as there isn't any object in the position 0 of index it has to instance the object. But the problem is that it is invoked Node() constructor before invoking tree.get(0). So, Why does Spring invokes the default constructor? How can I force it to use tree.get(0) to instance the object instead of Node()?</p>