2012-09-22 72 views
0

我有這樣的PHP服務。設置數據提供程序

<stockproductservice:StockproductService id="stockproductService" 
              fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
              showBusyCursor="true"/> 

它使用php服務。

我應該怎麼設置在itemRedenerer dataProvider中?

 <s:DataService source="{stockproductService.getAllStockproduct1()}"/> 

 <s:WebService source="{stockproductService.getAllStockproduct1()}"/> 

不工作。

+0

確定itemRenderer的沒有數據提供程序。它通常是具有dataProvider的ListBased組件的一部分,比如帶ArrayCollection作爲dataprovider的List。的itemRenderer是呈現在列表中的項目,並具有支柱組件:公共功能設定數據(值:對象){...}從ArrayCollection的接收對象。 DataService是負責從服務器獲取數據並例如創建ArrayCollection的部分。你應該以不同的方式陳述你的問題 –

+0

那麼,如何使用php服務設置dataProvider?顯然,php服務的結果不是數組集合。 – Samuel

回答

0

如果你的問題是如何建立一個WebService來填充在最簡單形式的數據提供程序也可能是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" creationComplete="creationCompleteHandler(event)" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> 

    <s:List dataProvider="{restaurants}" labelField="name" /> 

    <fx:Declarations> 
     <s:WebService id="RestaurantWS" wsdl="http://examples.adobe.com/flex3app/restaurant_ws/RestaurantWS.xml?wsdl" /> 
     <s:CallResponder id="getRestaurantsResult" 
         result="restaurants = getRestaurantsResult.lastResult as ArrayCollection"/> 
    </fx:Declarations> 

    <fx:Script> 
     <![CDATA[ 
      import mx.collections.ArrayCollection; 
      import mx.events.FlexEvent; 

      [Bindable] 
      public var restaurants:ArrayCollection; 

      protected function creationCompleteHandler(event:FlexEvent):void 
      { 
       getRestaurantsResult.token = RestaurantWS.getRestaurants(); 
      } 

     ]]> 
    </fx:Script> 
</s:Application> 
+0

我已經計算出如何創建物品轉換器。只要使用Data.XXXX這樣\t \t \t \t 可以填充結果的PHP服務。無論如何,感謝這個例子 – Samuel