1 Reply Latest reply on May 4, 2009 5:55 PM by Alex Glosband

    Trying to create an abstract service that supports both DataService(LCDS) and RemoteObject

    rdennisj
      I am trying to create a generic service processor in ActionScript that would be able to use a DataService(from LCDS) or a RemoteObject, depending on a property setting. The intent is to be able to change a setting during installation to control whether DataServices would be used, or RemoteObjects. I understand that the server side logic would need to be written differently for each of the implementations.
      The challenge is that accessing a DataService is synchronous, but a RemoteObject access is asynchronous.
      For the synchronous access, I can just call a service and return the result directly to an object which can be passed back to the client.
      For the asynchronous support, extra code must be written on the client side to listen for the return of a requested result (for example, the results of a database quesy). This code must be placed outside of the service itself, thus making the generic service non-generic.
      Are there any examples available that accomplish what I am trying to do?
        • 1. Re: Trying to create an abstract service that supports both DataService(LCDS) and RemoteObject
          Alex Glosband Adobe Employee

          Hi. As far as I know both DataService and RemoteObject are asynchronous APIs. If you call a DataService method such as fill() or call a method on your RemoteObject, code in your Flex application will continue to execute and the result from the RemoteObject or DataService request will be received asynchrounously. I don't believe there is any way currently to make synchronous or blocking calls in Flex because of the Flash Player's execution model.

           

          How are you planning on using the DataService and RemoteObject in your application? Is it to do something like populate a DataGrid? Do you plan on updating the data retrieved from the DataService or RemoteObject such as adding, updating or deleting records?

           

          The DataService API is much more powerful than the RemoteObject API, in that if you bind an ArrayCollection that is populated from a DataService to your DataGrid, when you update data in the DataGrid, the data on the server is updated and all other clients that have the same view of the data will also get the updates. You don't currently get this functionality with RemoteObjects.

           

          My point here is that if you wanted to write an abstract service that supports both DataService and RemoteObject and you need to be able to add, update or delete records you are going to need to write a lot of custom code to listen for collection change events when data on the client is modified and translate these change events into RemoteObject requests. Even if you did do that, other clients would not get these updates.

           

          If all you want to do is something simple like populate a DataGrid with data from the DataService or RemoteObject, then sure, writing an abstraction layer on the client that supports both of these wouldn't be hard.  

           

          -Alex