BlazeDS and ArrayList of custom objects

后端 未结 3 1712
余生分开走
余生分开走 2021-02-06 16:09

I\'m using BlazeDS to connect Flex with Java. I\'m having trouble passing ArrayLists of custom objects from Flex to java.

I have two objects, one is called Category,

3条回答
  •  礼貌的吻别
    2021-02-06 16:58

    One of the most common complaints with AS3 is the lack of typed arrays. ArrayLists will only contain objects, you will have to cast the results yourself.

    Here is an example of a Java and AS3 class that I would pass around.

    In Java:

    The top level class:

    package mystuff;
    
    public class StuffToSend
    {
        public List
    sections; ... }

    Sections class:

    package mystuff;
    
    public class Section
    {
        public List categories;
        ...
    }
    

    Category class:

    package mystuff;
    
    public class Category
    {
        ...
    }
    

    In AS3:

    package mystuff
    {
        [RemoteClass(alias="mystuff.StuffToSend")] // So AS3 knows which Java class to map
        public class StuffToSend
        {
            public var sections:ArrayCollection;
            ...
        }
    }
    
    package mystuff 
    {
        [RemoteClass(alias="mystuff.Section")] // So AS3 knows which Java class to map
        public class Section 
        {
            public var categories:ArrayCollection;
            ...
        }
    }
    
    package mystuff 
    {
        [RemoteClass(alias="mystuff.Category")] // So AS3 knows which Java class to map
        public class Category
        {
            ...
        }
    }  
    

    You can learn more about remoteObjects here: Data Access

提交回复
热议问题