1 Reply Latest reply on Jan 6, 2010 8:25 AM by flexy8

    Service call's lastResults will return empty rows when appended

    flexy8 Level 1

      I had a service binded to my button that when it is clicked, the items written on my text area will be read line by line and each lines will be passed as a parameter to a function call on my service. This call from a php function will simply do a search query (param%)  to my database and will return the values to my List. The problem is, there is an item added to my List but in the current code below, the items returned were just [Object AsyncToken]. How do I get the exact results returned from a database query to my Flex app?


      Changing the parameter of resArr.addItem( ); to getBarangaysByNameResult.lastResult will just return empty rows on my List. Also, if the value of the dataProvider property of my List will be changed to getBarangaysByNameResult.lastResult, only indeed the last result of my query will be returned. What I really wanted is that all the results of getBarangaysByNameResult.lastResult will be appended to my List.





      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:barangayservice="services.barangayservice.*">
                     import flash.events.MouseEvent;
                     import mx.collections.ArrayCollection;
                     import mx.controls.Alert;
                     private var line:RegExp = /([a-zA-Z\-,'ñ0-9 ]+)/g;
                     private var resArr:ArrayCollection;
                     protected function btnSearch_clickHandler(event:MouseEvent):void
                          var lineObj:Object = line.exec(taParse.text);
                          var lineArr:Array = [];
                          resArr = new ArrayCollection();
                          while (lineObj != null)
                               lineObj = line.exec(taParse.text);
                          for(var l:uint = 0; l < lineArr.length; l++)
                               getBarangaysByNameResult.token = barangayService.getBarangaysByName(lineArr[l].vars)
                               resArr.addItem(getBarangaysByNameResult.token = barangayService.getBarangaysByName(lineArr[l].vars));
                <s:CallResponder id="getBarangaysByNameResult"/>
                <barangayservice:BarangayService id="barangayService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           <s:Button x="253" y="186" label="Button" id="btnSearch" click="btnSearch_clickHandler(event)"/>
           <s:List x="117" y="220" width="206" id="listSearch" dataProvider="{resArr}" labelField="barangay_name" height="129"></s:List>
           <s:TextArea x="117" y="27" id="taParse" width="206"/>