title: ArrayList of custom Java objects over BlazeDS into AS3.0
body: <p>Right away i just try to explain  my problem:</p>
  
  <p>Using BlazeDS i got the following Javaclasses:</p>
  
  <p>DatabaseService.java:</p>
  
  <pre><code>public class Database {
  
   private Category helpCat = null;
  
  
   private Category root = new Category(1, "root", null, null);
   private List&lt;Article&gt; database;
  
  
   public Database()
   {    
  
  
    // ------------ tree -----------------------------------------------------------------------
    List&lt;Category&gt; level_one = new ArrayList&lt;Category&gt;();
    List&lt;Category&gt; level_two_computer = new ArrayList&lt;Category&gt;();
    List&lt;Category&gt; level_tree_hardware = new ArrayList&lt;Category&gt;();
  
    // Level 1
    Category buecher  = new Category(2, "buecher", root, null);
    Category computer  = new Category(3, "computer", root, level_two_computer);
    level_one.add(buecher);
    level_one.add(computer);
  
    //Level 2
    Category hardware  = new Category(4, "hardware", computer, level_tree_hardware);
    Category software  = new Category(5, "software", computer, null);
    level_two_computer.add(hardware);
    level_two_computer.add(software);
  
    //Level 3
    Category graphic  = new Category(6, "graphic", hardware, null);
    Category sound   = new Category(7, "sound", hardware, null);
    level_tree_hardware.add(graphic);
    level_tree_hardware.add(sound);
  
    // Level 0
    root.addChilds(level_one);
    // ------ tree end ----------------------------------------------------------------------------
  
    database = new ArrayList&lt;Article&gt;();
    try {
     add(new Book("Per Anhalter durch die Galaxis", "42", Articletype.BOOK, 795, "Per Anhalter durch die Galaxiss", "Douglas Adams", "Heyne Verlag", "Taschenbuch", "3453146972"), buecher);
     add(new Book("Harry Potter und der Stein der Weisen", "descriptionShort", Articletype.BOOK, 1299, "Harry Potter und der Stein der Weisen", "Joanne K. Rowling", "Carlsen Verlag GmbH", "gebunden", "3551551677"), buecher);
     add(new Book("Harry Potter und die Kammer des Schreckens", "descriptionShort", Articletype.BOOK, 1499, "Harry Potter und die Kammer des Schreckens", "Joanne K. Rowling", "Carlsen Verlag GmbH", "gebunden", "3551551677"), buecher);
     add(new Hardware("nVidia GeForce 8400GS", "Graphikkarte", Articletype.HARDWARE, 2665, "512 GDDR5 Speicher, DVI, 1 GPU", "MSI", "neu"), graphic);
     add(new AKW("Biblis C", "Druckwasserreaktor, Preis auf Anfrage, Nur Selbstabholer", Articletype.AKW, -1, "Biblis", 0, 2525, "Siemens", 1, 2012), software);
    } catch (Exception e) {
  
     e.printStackTrace();
    }
   }
  
   public List&lt;Category&gt; getCategories(String node) {
    if(node.equalsIgnoreCase("root"))
     return root.getChildren();
  
    Category baum = null; 
    baum = get_node_by_name(root, node);
  
    return baum.getChildren();
  
   }
  
   private Category get_node_by_name(Category localroot, String lookfor)
   {
    helpCat = null;
    if(localroot.getChildren() != null)
    {
     for (int i = 0; i &lt; localroot.getChildren().size(); ++i)
     {
      if(!(localroot.getChild(i).getName().equals(lookfor)))
      {
       get_node_by_name(localroot.getChild(i), lookfor);
      }
      else
      {
       helpCat = localroot.getChild(i);
       helpCat.setParent(null);
      }
     }
    }
    return helpCat;
   }
  
   public List&lt;Article&gt; search(int artID, String name, Category categorie){
    List&lt;Article&gt; ergebnis = new ArrayList&lt;Article&gt;();
    if (artID &gt;= 0)
    {
     for(int i = 0; i&lt; database.size(); ++i){
      if(database.get(i).getID() == artID)
      {
       ergebnis.add(database.get(i));
       return ergebnis;
      }
     }   
    }
  
    if (name != null){
     for(int i = 0; i&lt;database.size(); ++i){
      if (database.get(i).getName().equalsIgnoreCase(name))
       ergebnis.add(database.get(i));
     }
     return ergebnis;
    }
    if (categorie != null){
     {
      ergebnis.addAll(categorie.getArticles());
     }
     return ergebnis;
    }
  
    return database;
   }
  
  
   public Article add(Article newArticle, Category cat) throws Exception
   {
    newArticle.addCategory(cat);
    if(newArticle.getID() != 0)
    {
     throw new Exception("Die Artikel ID wird vom DBS festgelegt!");
    }
  
    if (database.isEmpty())
    {
     newArticle.setID(0);
    }
    else
    {
     newArticle.setID(database.get(database.size() - 1).getID()+1);
    }
  
    database.add(newArticle);
  
    return newArticle;
   }
  
  }
  </code></pre>
  
  <p>And the Category Class:</p>
  
  <pre><code>  public class Category {
   private int idCat;
   private String nameTEST;
   private Category parent = null;
   private List&lt;Article&gt; articles = new ArrayList&lt;Article&gt;();
   private List&lt;Category&gt; children = new ArrayList&lt;Category&gt;();
  
  
   public Category(int _id, String _name, Category _parent, List&lt;Category&gt; _children)
   {
    if(_id &gt; 0)
     idCat = _id;
    if(_name != null)
     nameTEST = _name;
    if(_parent != null)
     parent = _parent;
    if(_children != null)
     children = _children;
   }
  
   public String toString()
   {
    return nameTEST;
   }
  
   void addArticle(Article article){
    articles.add(article);
   }
  
   public List&lt;Article&gt; getAllArticles(){
    List&lt;Article&gt; ergebnis = this.getArticles();
  
    for (int i = 0; i&lt;children.size();++i){
     ergebnis.addAll(children.get(i).getAllArticles());
    }
  
    return ergebnis;
   }
  
   public void setID(int iD) {
    idCat = iD;
   }
  
   public int getID() {
    return idCat;
   }
  
   public void setName(String name) {
    this.nameTEST = name;
   }
  
   public String getName() {
    return nameTEST;
   }
  
   /**
    * @param parent the parent to set
    */
   public void setParent(Category parent)
   {
    this.parent = parent;
   }
  
   /**
    * @return the articles
    */
   public List&lt;Article&gt; getArticles()
   {
    return articles;
   }
  
   public void addChilds(List&lt;Category&gt; _next)
   {
    for (int i = 0; i &lt; _next.size(); ++i)
    {
     children.add(_next.get(i));
    }
   }
  
   public void addChild(Category one_next)
   {
    children.add(one_next);
   }
  
   public Category getChild(int index)
   {
    return children.get(index);
   }
  
   public void removeChild(Article article){
    articles.remove(article);
   }
  
   public List&lt;Category&gt; getChildren()
   {
    return this.children;
   }
  }
  </code></pre>
  
  <p>also there are of course classes for articles and so on, but thats not important at that point. </p>
  
  <p>the counterpart in flex looks like this:</p>
  
  <p>Category.as</p>
  
  <pre><code>[RemoteClass(alias="PACKAGE.Category")]
   public class Category
   {
    private var idCat:int     = -1;
    private var nameTEST:String    = null;
    private var parent:Category    = null;
    private var articles:ArrayCollection = new ArrayCollection;
    private var children:ArrayCollection = new ArrayCollection;
  
    public function Category(id:int, name:String, parent:Category, childlist:ArrayCollection, articles:ArrayCollection = null)
    {
     this.idCat   = id;
     this.nameTEST  = name;
     this.parent  = parent;
     this.articles = articles;
     this.children = childlist;
    }
  
    public function setChildren(childList:ArrayCollection):void
    {
     this.children = childList;
    }
  
    public function getChildren():ArrayCollection
    {
     return this.children;
    }
  
    public function getName():String
    {
     return this.nameTEST; 
    }
   }
  </code></pre>
  
  <p>Then i got a Flex service class calling BlazeDS and executing the getCategories java method. Since Flash dosn't seem to understand typed arrays, the result from that method which i get back in flex is a simple array of untyped objects (the mapping dosn't seem to work here, even tought the class category exists in flex and has the same properties).
  thats the first thing. but however, i'm converting the untyped objects manually into objects of the category.as class.</p>
  
  <p>the second thing is that categories have child-categories within the java object, which are also ArrayLists of the type category.java. the problem about that: my result event object only contains the first level of categories, looking into them the children are allways null. i dunno why they are empty, since they ARE part of the java object category.</p>
  
  <p>and the third thing (the strangest by fast), you maybe noticed i named the properties of the category.java class strange, like idCat and nameTest instead of simply id and name. why that? because the property names of my flex result objects dont seem to change when i change the java objects properties names (result object properties are named "id" and "name" but the java class object properties are named "idCAT" and "nameTEST"). that it REALLY strange, since if i set the properties, like you see at nameTEST = "TESTNAME" it IS recogniced by flex, only the proertyNAMES dont seem to be recognized at all.</p>
  
  <p>is blaze DS saving / caching the mapping configuration somewhere? how do i get it to rebuild the hole mappings IF so?</p>
  
  <p>that could also explain my problem about the untyped objects i get from java, since before i changed the lists into ArrayLists they where vectors ( which blazeDS dosn't support AFAIK), and maybe not only the propertynames, but also the propertytypes are hard-mapped at some wired place and blazeds just dosn't get them refreshed.</p>
  
  <p>i really like checked everything 5 times by now, even redeployed blazeds on the server to make sure no mappings left, but it didnt help at all.</p>
  
  <p>ANY ideas what i could do? (exept changing to another serializer then blazeds (thats what i'm going to do if everything else fails...)) </p>