3 Replies Latest reply on Jan 11, 2012 12:56 PM by Claudiu Ursica

    Remoting with value objects and MVC - This should be easy


      Hi, I have this projects where I remotely get data from MySQL using the Zend framework. The data is formatted as a value object. In my controller, I have an eventListener for when the results come back. The simple task I am trying to do is to update the model when the results are in. I spend a great deal of time already searching the net and trying different approaches with no success so, in desperation, I figured I will post here and see if someone knows how to do that. Looking at the debugger I know the requested data is fetched properly by the remote command - that said, the data is arriving as mx.utils.ObjectProxy, not as my strong typed VO. Here goes:


      In my model I have:



      private var _subList:myRegVO;


      (note: all the valueObjects imports are in place in the model and the controller)

      then I have the getter and setter.


      public function get subList():myRegVO


           return _subList;



      public function set subList(v:myRegVO):void


           _subList = v;

           dispatchedEvent(new Event(SUBLIST_CHANGED));



      (not quite sure if the object will copy itself here or if a deep copy process need to be put in place. I tried with ObjectUtil.copy/clone without any success: I got implicit coercion errors)


      then in my controller I have the result event handler


      protected function changeListResultHandler(event:ResultEvent):void




                _model.subList = event.result.object_proxy as myRegVO;




                Alert.show("No results returned")




      No matter which permutation I tried, my subList VO remains null. Any ideas how to get the data from the remoting and assigning it to the VO inside the model? 

      This should be simple (1) got the result (event.result), (2) take the results, store them in the model and go on with an event dispatcher. Somehow, it is not that easy...            


      Thanks for any help with this.