Adobe Flex 3 Help

Remote data in data provider components

You use Flex data access components: HTTPService, WebService, and RemoteObject, to supply data to Flex data provider components. For more information, see Accessing Server-Side Data with Flex.

To use a remote data source to provide data, you represent the result of the remote service with the appropriate object, as follows:

  • A RemoteObject component automatically returns an ArrayCollection for any data that is represented on the server as a java.util.List object, and you can use the returned object directly.
  • For HTTPService and WebService results, cast the result data to a collection class if the data changes or if you use the same result in multiple places (the latter case is more efficient). As a general rule, use an ArrayCollection for serialized (list-based) objects and an XMLListCollection for XML data.

The following code snippet shows this use, casting a list returned by a web service to an Array in an ArrayCollection:

    <mx:WebService id="employeeWS" wsdl"http://server.com/service.wsdl"
        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 data access component, see Accessing Server-Side Data with Flex.