0 Replies Latest reply on Jan 7, 2010 12:15 PM by zumorito

    Bindable variable and WebServices

    zumorito

      Hi,

        I am new to flex and am trying to create a simple interactive application which interacts with a Web service.

      I am using a button to trigger the web service call and want to display the data in a data grid component. I also have a Combo box which i am populating with the first column of the same web service's result set.

       

      The problem I am facing is that both the components seem to have a lag of one click. Which means, when i click the Get Data button to trigger the web service call the first time, the web service returns data (verified by the web service logs) but it is not displayed on the data grid. The next time i click on the Get Data button, the data is displayed.

       

      I have pasted the code below. Please let me know where i have gone wrong in it.

       

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

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

      backgroundGradientColors="[0xFFFFFF,0xAAAAAA]"

      horizontalAlign="left"

      verticalGap="15" horizontalGap="15" >

       

      <mx:WebService id="dataFetching"

      wsdl="http://localhost:8080/SRS/services/KeyDriversChainDataService?wsdl"

      fault="mx.controls.Alert.show(event.fault.faultString)"

      >

           <mx:operation name="getMRSMarkets">

              <mx:request>

                    <viewType>DSB</viewType>

                   <category>HOTS</category>

                   <segment>ALL</segment>

                   <tradingCo>ALL</tradingCo>

                   <brand>ALL</brand>

                   <timeframe>Weekly-TABLE</timeframe>

                   <analyticType>SUMMARY</analyticType>

                   <market>Total Coverage</market>

                   </mx:request>

          </mx:operation>

      </mx:WebService>

       

      <mx:Script>

           <![CDATA[

                    import mx.collections.ArrayCollection;

                    import mx.rpc.events.ResultEvent;

                    import mx.rpc.events.FaultEvent;

       

                    [Bindable]

                    public var distinctMrkt:ArrayCollection;

       

                 

                private function getMarkets(): void{

                     dataFetching.getMRSMarkets.send();

                     distinctMrkt = dataFetching.getMRSMarkets.lastResult as ArrayCollection;

                     table.dataProvider = distinctMrkt;

                }

       

          

                private function showGraph(market:String):void{

                     selected.text=market;

                }

      ]]>

       

      </mx:Script>   

       

       

      <mx:Button id="datafetch" label="Get Data" click="getMarkets()"/>

       

       

      <mx:DataGrid id="table" width="100%" >

           <mx:columns>

                <mx:DataGridColumn dataField="a1_market" headerText="Market"/>

                <mx:DataGridColumn dataField="a2_analytic_type" headerText="Analytic Type"/>

           </mx:columns>

      </mx:DataGrid>

       

       

      <mx:ComboBox id="dropdown" dataProvider="{distinctMrkt}" labelField="a1_market"

      click="showGraph(dropdown.selectedLabel)"/>

       

       

      <mx:HBox>

                <mx:Label text="Selected item is: "/>

                <mx:Label id="selected" />

       

      </mx:HBox>

       

       

      </mx:Application>