3 Replies Latest reply on Nov 11, 2009 12:48 PM by salem_b_a

    How to fill an Array with results from a CallResponder?

    petousas

      I want to fill an Array with the resuls of my data servic(witch returns an array with objects)

      <s:CallResponder id="getRatesBetweenByIdResult"/>
      <ratescontroller:RatesController id="ratesController" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
      
      

      I have succesfully filled a datagrid specyfing

      getRatesBetweenByIdResult.token = ratesController.getRatesBetweenById(query);
      and
      <mx:DataGrid x="433" y="258" id="dataGrid"  dataProvider="{getRatesBetweenByIdResult.lastResult}">
      

       

      But after that is very difficult to get the actually data from dataGrid. I tryed this but didnt work

       

      var p:String = dataGrid.data[0].price; //where price one of my Datagrid Column
      

       

      Actually i don't need the dataGrid to appear in my design but is the only way i know to get data from my dataservices.

       

       

      Using Flash Builder 4beta2 with zend amf.

      Thanks for any hint or suggestion

        • 1. Re: How to fill an Array with results from a CallResponder?
          Subeesh Arakkan Level 4

          Hi,

           

          There is no need to use a DataGrid just for getting the array from the service. After you import the Webservice, create an instance of it .Set an ID, create result and fault handlers.Check this code snippet ( GlobalWeather is the WebService I have used for testing).

           

          <fx:Declarations>
               <globalweather:Globalweather id="service" result="service_resultHandler(event)" 
                                                        fault="service_faultHandler(event)"/>
          </fx:Declarations>
          

          Invoke the service the service. ( GetWeather is a valid method in the service )

          service.GetWeather("India");
          

           

          Put a break point in the result Handler and you will find the array in the event.result object

          protected function service_resultHandler(event:ResultEvent):void
          {
               // Result array will be in event.result
          }
          
          • 2. Re: How to fill an Array with results from a CallResponder?
            petousas Level 1

            thanks for the hint.It works if my services returns one result.But not works with many.

             

            I want to fill an Array with the resuls of my data service(witch returns an array with MANY objects)

             

             // Result array will be in event.result

            The event.result has my array of objects BUT typecasted as OBJECT and i can't access all the values .

             

             

            The API says:

             

            mx.rpc.events.ResultEvent.result():Object
            [Read Only] Result that the RPC call returns.


            Also the compiler don't let me to  hard typecast an object to Array


            thanks for any help
            • 3. Re: How to fill an Array with results from a CallResponder?
              salem_b_a Level 2

              hi,

               

              try this

               

              when handling the result,

               

              var aux:Array = new Array(event.result[0]);

               

               

               

               

               

               

               

              ---------------------------------------------------------------------------

              if this post helped, please mark