View comments | RSS feed

Using remote data providers

You can use the following types of remote data providers for Flex components:

The following sections describe how you can use these remote data sources to provide data. For more information on using remote data providers see Using RPC Components.

Subtopics

Using an RPC data source
Using a DataService component
Using paged remote data providers.

Using an RPC data source

To use an RPC data source, you represent the result of the remote service by using the appropriate class as follows:

The following code excerpt shows this use, converting a list returned by a web service to an 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%">

For more information on using RPC data sources, see Using RPC Components.

Using a DataService component

To use a DataService component as a data provider, you call the component's fill() method to fill an ArrayCollection object with the data from a Data Management Service destination, as the following code excerpt shows:

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

For more information on using DataService components, see Distributing Data in Flex Applications.


Flex 2

Comments


mpeterson said on Jun 30, 2006 at 12:13 PM :
Instances of "faultstring" on this page should be "faultString".
- Mike Peterson
Adobe Flex documentation team

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/2/docs/00000514.html