title: How to assign values for a list of some objects defined as variable with Spring Expression Language(Or the other expression languages you aware of)
body: <p>In Spel, it is easy to assign some values for a List property.
  For example having object foo with a property defined as List, I usually do:</p>
  
  <pre><code>SpelParserConfiguration config = new SpelParserConfiguration(true,true);
  ExpressionParser parser = new SpelExpressionParser(config);
  Foo foo = new Foo();
  EvaluationContext context = new StandardEvaluationContext(foo);
  parser.parseExpression("barList[1].test='11111111'")
      .getValue(context);
  </code></pre>
  
  <p>But what do you do for the case you want to assign values for a given List
  defined as a variable in a method. e.g:</p>
  
  <pre><code>List&lt;String&gt; fooList = new ArrayList&lt;String&gt;();
  context = new StandardEvaluationContext(fooList);       
  parser.parseExpression("SOMETHING[0]='come on'")
  .getValue(context);
  </code></pre>
  
  <p>In the above example, I don't know what to put instead of SOMETHING to make this work.
  If I put "fooList[0]='....'", it throws an exception complaining there is no fooList property in fooList.</p>
  
  <p>If I put "[0]='....'", it throws Unable to grow collection: unable to determine list element type.</p>
  
  <p>Then I came to define a generic wrapper like this:</p>
  
  <pre><code>public static class SpelWrapper&lt;T&gt;
  {
      T obj;
  
      public SpelWrapper(T obj)
      {
          this.obj = obj;
      }
  
      public T getObj() {
          return obj;
      }
  
      public void setObj(T obj) {
          this.obj = obj;
      }
  }
  </code></pre>
  
  <p>and then tried to test this one:</p>
  
  <pre><code>List&lt;String&gt; fooList = new ArrayList&lt;String&gt;();
      SpelWrapper&lt;List&lt;String&gt;&gt; no = new SpelWrapper&lt;List&lt;String&gt;&gt;(fooList);
      context = new StandardEvaluationContext(no);
  
      parser.parseExpression("obj[0]='olaaa'")
      .getValue(context);
  </code></pre>
  
  <p>But it did not work and still get this ugly  message: </p>
  
  <pre><code>Unable to grow collection: unable to determine list element type
  </code></pre>
  
  <p>I tried other expression languages like MVEL, OGNL, JEXL but I noticed they don't support auto null reference initialization which is important for me. However they did not seem to have a solution around above problem either.</p>
  
  <p>I also started to think what if what I need is not a case for expression languages!
  The thing is my need is not just defining a variable and try to assign values using an EL.</p>
  
  <p>In my case I have some simple POJO domain class beans and Some input Strings like </p>
  
  <pre><code> "bar[0].foo.value=3434"
  </code></pre>
  
  <p>Now I should be able to create List of Bar and put a Bar instance as its first element, then set foo property with a Foo instance and finally set Foo's value as 3434.</p>
  
  <p>Any idea around this issue?</p>
  
  <p>Thanks in advance </p>
  
  <p><strong>Eit</strong>
  I was wrong in "However they did not seem to have a solution around above problem either". For example in MVEL, this a very easy task to do. But unfortunately the SPLE's ability to auto expanding lists and automatically assigning initiators in null chains makes it incredibly proper for my case.  </p>