设置Dataprovider

时间:2012-09-22 07:59:44

标签: flex

我有这样的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()}"/>

无效。

1 个答案:

答案 0 :(得分:0)

如果您的问题是如何设置WebService以最简单的形式填充dataProvider,可能是这样的:

<?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>