0 Replies Latest reply on Jul 9, 2015 2:21 AM by giacomo.c

    Valorize actionScript Array with data coming from java backend server (BlazeDS)

    giacomo.c

      Hi all guys and thank you in advance.

       

      I'm a junior developer working for a little company and I have right here a java - flex (BlazeDS) project. My issue is to understand how a determined variable takes value when its respective java remoteObject is called. Below a little bit of code to make you understand:

       

      Home.as (Imported in Home.mxml)

      [Bindable] private var _listSearch:ArrayCollection = new ArrayCollection;

      private var _sql:String;

      private var _dm:DataManager;

      private function load_OnClick(event:Event):void {

           var _dm = new DataManager;    

           .....

           .....

           _sql = "SELECT * from....";

           _dm.getData(_listSearch, _sql);   // In the Home.mxml I have a DataGrid with data provider _listSearch

      }


      DataManager.as

      class DataManager {

           private var _service:RemoteObject;

           private var loCs:ChannelSet = new ChannelSet();


      public function DataManager() {

           _servizio = new RemoteObject("dataManager");         

           loCs.addChannel(new AMFChannel("canale", "http://localhost:8080/MyProject/messagebroker/amf"));

           _servizio.channelSet = loCs;

       

               if(!_servizio.hasEventListener(ResultEvent.RESULT)) {   

               _servizio.addEventListener(ResultEvent.RESULT, resultHandler);   

            }

            if(!_servizio.hasEventListener(FaultEvent.FAULT)) {   

                _servizio.addEventListener(FaultEvent.FAULT, faultHandler);

            }

      }


      private function resultHandler(event:ResultEvent):void {

      var _result:ArrayCollection = new ArrayCollection;

      _result = event.result as ArrayCollection;

      }


      public function getData(paResultVar:ArrayCollection, paSql:String):void {

      var _res:ArrayCollection = new ArrayCollection;

      _servizio.getData.send(_res, paSql); // Suppose I have a java class named DataManager with getData method who just do the query and return the                                      // result

      }


      Than my doubt is that I have many method similar to getData who calls respective methods in DataManager.as who make the send() call to DataManager.java. But I have to find the result of all these call in resultEvent method! A button click can generate ten method calls wich have to valorize ten array... How can I know when resultEvent contains data of array number two, or three, or four...


      Please Help me guys and sorry for my english.