title: Handling Lists of complex objects in Javascript/JSP
body: <p>This is my server side class</p>
  
  <pre><code>public class DefinitionT implements java.io.Serializable {
  
  private int id;
  private String value;
      .....
  </code></pre>
  
  <p>the two fields have getters and setters.
  On my JSP side I have a var declared as</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      var g_definitions="&lt;s:property value="definitions"/&gt;";
  &lt;/script&gt;
  </code></pre>
  
  <p>My Struts Action has a getter called getDefinitions which gets called and returns a list of DefinitionT objects.<br>
  In my JS I have the following code</p>
  
  <pre><code>    for( var i = 0; i &lt; 2; i++ ) 
  { 
      $("#definitionsDiv").append(g_definitions[i].value);
  }
  </code></pre>
  
  <p>Firstly I was trying to figure out how to get the number of objects in the list but 
  g_definitions.size   is "Undefined"
  If I try to access g_definitions[0].value it is also undefined.
  How do I handle this list properly?  </p>