Expand my Community achievements bar.

Objects returned by a java list not getting deserialized

Avatar

Level 1

Hi

I am calling a java function which return a list. This list include two types of object say Gallery and galleryGroup. These objects have implemented Externalizable interface. There are corresponding object in Flex say Gallery and GalleryGroup, which also implement IExternalizable interface.

A call has been made to java object to return the list which include object of Gallery and GalleryGroup. If object Gallery  is not instantiated before the result is received, It gives following error.

ArgumentError: Error #2173: Unable to read object in stream.  The class Gallery does not implement flash.utils.IExternalizable but is aliased to an externalizable class

If I create an object of Gallery i.e var galObj:Gallery = new Gallery();

before a call on remote object, result is retrieved successfully.

Is there a way to handle this error?

Thanks

Ajay

3 Replies

Avatar

Level 3

Hi,

          Try to TypeCast the Result to Your FlexObject;

           var galleryObject:GalleryObject=GalleryObject(result);

Avatar

Level 1

The result from the server is an ArrayCollection, which include two type of objects. I am already type casting the result to an ArrayCollection. Probably I could'nt make you understand the problem.

I state the problem again.

The result from the server is in the form of ArrayCollection, which should have two type of objects say "A" and "B". Since "A" has not been instantiated before the result is received  from server, flex throws the error.

Ajay

Avatar

Level 3

HI,

          You can iterate through the loop and you can get the Objects inside the List right.

          for(var i:int=0;i<arr.length();i++){

          if(i==0){

                                   var obj:Object=new Object();

                                   obj=arr.getItem(i);

                                  //try to Typecast to Your Objecty

                         }

         if(i==1)

                         {

                                     var obj:Object=new Object();

                                   obj=arr.getItem(i);

                                  //try to Typecast to Your Objecty

                         }

                       But Before that try to TypeCast your Result to ArrayCollection.

                        var arr:ArrayCollection=new ArrayCollection();

                         arr=event.result as ArrayCollection();

          }