Hello,
Im having problem getting the data from java to flex 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 

Reply via email to