リモートデータプロバイダの使用

Flex コンポーネントでは、次の種類のリモートデータプロバイダを使用できます。

以降のセクションでは、これらのリモートデータソースを使用してデータを提供する方法について説明します。リモートデータプロバイダの使用の詳細については、RPC コンポーネントの使用を参照してください。

サブトピック

RPC データソースの使用
DataService コンポーネントの使用
ページング対応のリモートデータプロバイダの使用

RPC データソースの使用

RPC データソースを使用するには、次のように適切なクラスを使用してリモートサービスの結果を表します。

次の抜粋されたコードはこの使い方を示しており、Web サービスから返されたリストを ArrayCollection に変換しています。

    <mx:WebService id="employeeWS" destination"employeeWS"
        showBusyCursor="true"
        fault="alert(event.fault.faultstring)">
        <mx:operation name="getList">
            <mx:request>
                <deptId>{dept.selectedItem.data}</deptId>
            </mx:request>
        </mx:operation>
.
.
    </mx:WebService>

    <mx:ArrayCollection id="ac"
        source="mx.utils.ArrayUtil.toArray(employeeWS.getList.lastResult)"/>
    <mx:DataGrid dataProvider="{ac}" width="100%">

RPC データソースの使用の詳細については、RPC コンポーネントの使用を参照してください。

DataService コンポーネントの使用

データプロバイダとして DataService コンポーネントを使用するには、次のように、コンポーネントの fill() メソッドを呼び出して、Data Management Service の宛先からのデータを ArrayCollection オブジェクトに格納します。

<mx:Script>
    <![CDATA[
        import mx.data.DataService;
        import mx.collections.ArrayCollection;
        
        public var ds:DataService;
        [Bindable]
        public var contacts:ArrayCollection;

        public function initApp()
        {
            contacts = new ArrayCollection();
            ds = new DataService("contact");
            ds.fill(contacts);    
        }
    ]]>
</mx:Script>
.
.
        <mx:DataGrid id="dg" dataProvider="{contacts}" editable="true">

DataService コンポーネントの使用の詳細については、アプリケーションでのデータの分散を参照してください。


Flex 2.01