2 Replies Latest reply on Jun 14, 2011 6:04 AM by brendalc1636

    Flex data service not returning strongly typed objects


      Hello everyone! I am having a problem with Flex data services. I read data in from many tables in my database, but I am not always returned my strongly typed objects like I had hoped. Many of my ArrayCollections are filled with ManagedObjectProxy objects and many are my stongly typed objects.


      I am calling my data service fill method through action script in a command (we are using cairngorm). My execute method of the command sets up the data service and calls the fill method:


      var getTermDS:DataService = new DataService("sql-reftermination");

      getTermDS.autoCommit = true;

      getTermDS.autoSyncEnabled = true;

      getTermDS.channelSet = channelSet;

      getTermDS.addEventListener("result", resultHandler);

      getTermDS.addEventListener("fault", faultHandler);

      getTermDS.fill(terminationReasons, "all");


      In my data-management-config.xml file, my actionscript-class is set to my object name (valueObjects.TerminationReasonsObject). My object in Flex is surely in that package.


      package .valueObjects




      public class TerminationReasonsObject


      public var TERM_REASON_ID:String;

      public var TITLE:String;





      Originally I had TERM_REASON_ID as a Number, but when I looked at the ManagedObjectProxy it seemed to be coming in as a string.


      I read that you need to reference your object in your code to get the strongly typed objects.  Just above where I set up my data service I have a line and it doesn't seem to help:


      var terminationReason:TerminationReasonsObject


      Does anyone have any suggestions of why I am receiving ManagedObjectProxys?


      Thank you!


        • 1. Re: Flex data service not returning strongly typed objects
          Flex harUI Adobe Employee

          I'm not an expert in that area, but don't you need metadata that looks

          something like this?



          • 2. Re: Flex data service not returning strongly typed objects
            brendalc1636 Level 1

            I was getting this problem with the ManagedObjectProxy objects for various objects. I was finally able to get one to come in as a strong typed ActionScript object after many months. I finally had the right combination of things:


            1. Be sure that the ActionScript object has the correct type for the properties on your ActionScript value object. For example, for some reason I had a property typed as an int when it should have been a number.


            2. The RemoteObject metadata tag must not have any alias in it. It must be blank.


            3. In the code that is handling the fill method, you must have a reference to the ActionScript object. For example, when bringing in objects of TerminationReasonsObject, somewhere at the top of the class I needed the code:

                 var terminationReasonsObject:TerminationReasonsObject = new TerminationReasonsObject();