Hello,
I have similar problem and im totally new to flex and cairngorm... here is
my code snippet:

im my java end:

 List<Users> getAll() {  // from hibernate dao then return result which
llist of users }

in AS files:

public class ListDelegate extends EventDispatcher
        {
                private var userService:RemoteObject;
                private var responder:IResponder;
                
                public function ListDelegate(responder:IResponder)
                {
                        this.userService = new  RemoteObject("userService");
                        
                        this.responder = responder;
                }
                
                public function getUserList():void
                {
                        
                var call : Object = userService.getAll();
                
                        call.addResponder( responder );
                        
                }
        }


public class ListUserCommand extends BaseCommand
        {
                
                
                override protected function callDelegate():void
                {
                        var listdelegate:ListDelegate = new ListDelegate(this);
                        listdelegate.getUserList();
                }
                
                override public function result( event : Object ) : void
                {                               
                        this.modelHelper.onResultUser(event);   
                                
                }               
        
                override public function fault( event : Object ) : void
                {
                        var faultevt:FaultEvent = event as FaultEvent;
                        Alert.show(faultevt.fault.rootCause.toString());
                }

        }

public class ModelHelper
        {
                [Bindable]
                public var userlist: UserList;
                
                public function ModelHelper(userlist: UserList)
                {
                        this.userlist = userlist;
                }
                
                public function getUserList():void
                {
                        new ListUserEvent(this).dispatch();
                }
                
                public function onResultUser(event:Object):void
                {
                        this.userlist.listusers = event.result as 
ArrayCollection;
                }

        }

..and i use DataGrid to display datas:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; 
        initialize="init()"
        creationComplete="loadAll()" >
        
        <mx:Script>
        <![CDATA[
                import com.test.flex.util.UserList;
                import mx.rpc.events.ResultEvent;
                import com.test.flex.model.ViewModelLocator;
                import com.test.flex.events.ListUserEvent;
                import com.test.flex.model.ModelHelper;
                
                [Bindable]
                private var modelLocator:ViewModelLocator =
ViewModelLocator.getInstance();
                
                [Bindable]
                public var modelHelper:ModelHelper;
                [Bindable]
                public var users:UserList;
                
                public function init():void
                {
                        this.users = new UserList();
                        this.modelHelper = new ModelHelper(users);      
                                
                }
                
                public function loadAll():void
                {
                        this.modelHelper.getUserList(); 
                }
                
                
                
        ]]>
 </mx:Script>
 
 <!-- mx:Label text="{modelLocator.test}"/ -->
 
 <mx:DataGrid id="userlist" dataProvider="{modelHelper.userlist.listusers}">
        <mx:columns>
                <mx:DataGridColumn headerText="ID" dataField="id"/>
                <mx:DataGridColumn headerText="Username" dataField="username"/>
                <mx:DataGridColumn headerText="Password" dataField="password"/>
        </mx:columns>
 </mx:DataGrid>
 
        
        <mx:Button id="logout" label="LogOut"
click="{modelLocator.modelWorkflowState = ViewModelLocator.LOGIN_SCREEN}"/>
</mx:VBox>

..and the rest are straigthforward code. When I change the return value to
String it works fine nut when put it back to List it display nothing or
error i get but when i debug it i gets the results:

11:20:14,459 INFO  [STDOUT] Hibernate: select this_.ID as ID1_0_,
this_.USERNAME as USERNAME1_0_, this_.PASSWORD as PASSWORD1_0_ from user
this_
11:20:14,464 INFO  [STDOUT] [BlazeDS]12/02/2008 [DEBUG] [Service.Remoting]
Adapter 'java-object' called 'userService.getAll(java.util.Arrays$ArrayList
(Collection size:0)
)'
11:20:14,465 INFO  [STDOUT] [BlazeDS]12/02/2008 [DEBUG] [Service.Remoting]
Result: 'java.util.ArrayList (Collection size:2)
  [0] = com.test.flex.model.User
    id = 1
    username = eman
    password = password

  [1] = com.test.flex.model.User
    id = 2
    username = test
    password = password

'
11:20:14,465 INFO  [STDOUT] [BlazeDS]12/02/2008 [DEBUG] [Message.RPC] After
invoke service: remoting-service
  reply: java.util.ArrayList (Collection size:2)
  [0] = com.test.flex.model.User
    id = 1
    username = eman
    password = password

  [1] = com.test.flex.model.User
    id = 2
    username = test
    password = password
11:20:14,467 INFO  [STDOUT] [BlazeDS]12/02/2008 [DEBUG] [Endpoint.AMF]
Serializing AMF/HTTP response
Version: 3
  (Message #0 targetURI=/3/onResult, responseURI=)
    (Externalizable Object #0 'DSK')
      (Externalizable Object #1 'flex.messaging.io.ArrayCollection')
        (Array #2)
          [0] = (Typed Object #3 'com.test.flex.model.User')
            id = 1
            username = "eman"
            password = "password"
          [1] = (Typed Object #4 'com.test.flex.model.User')
            id = 2
            username = "test"
            password = "password"
1.228188014466E12
(Byte Array #5, Length 16)
(Byte Array #6, Length 16)
(Byte Array #7, Length 16)


What im missing here?
Thanks a lot.
Cheers.

-eman


Sujit Reddy wrote:
> 
> If you are mapping the AS object to the Java class using the RemoteClass
> metatag, that will do the work. just make sure the name of the Java class
> in
> the RemoteClass metatag has the fully qualified name i.e. com.xxx.remoting
> .<classname>
> 
> You need not de-serialize the arraylist, if the mapped objects are passed
> in
> the ArrayList from Java, you get them as the objects in ArrayCollection in
> AS.
> 
> did you include the reference to the AS object mapped to the Java object
> in
> you main application file? if a reference of AS object is not included in
> the main application file, then that class definition will not be
> available
> during runtime.
> 
> If any of the above suggestions are not helping you, share few code
> snippets
> from your application, we can try to debug the problem.
> 
> Regards,
> Sujit Reddy G
> 
> On Thu, Feb 21, 2008 at 12:58 AM, [p e r c e p t i c o n] <
> [EMAIL PROTECTED]> wrote:
> 
>>   just noticed that the namespaces are different...would this matter? on
>> the POJO it com.xxx.remoting, but on the AS3Object it just package...
>> percy
>>
>>
>> On Wed, Feb 20, 2008 at 10:12 AM, [p e r c e p t i c o n] <
>> [EMAIL PROTECTED]> wrote:
>>
>> > Hi Again,
>> > Ok...so by instantiating my class the Serialization took place and
>> there
>> > are 99 elements of that type in the result...however the members of the
>> > class are all null, but i'm printing them to a file on the Java side so
>> I
>> > know that there are values in each object...any ideas on why this is
>> > happening?
>> >
>> > thanks so much for all your input!
>> > percy
>> >
>>
>>  
>>
> 
> 
> 
> -- 
> Regards,
> Sujit Reddy. G
> 
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-de-serialize-objects-tp15582296p20786063.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to