2 Replies Latest reply on Feb 21, 2011 10:49 PM by Flex harUI

    Object cast - J2EE to ActionScript strange problem

    Ztere0 Level 1



      I am working in a project with multiple layers composed by Flash+Flex; BlazeDS; J2EE+Hibernate.


      I have some services to get all the data from database and I have a strange problem when I try to cast some objects from J2EE to ActionScript via BlazeDS Services. This is the structure that I have in my project:




      Table ServicePetitions (a table with all the data about a service petition)




      ServicePetition object (mapping object generated by hibernate)

      ServicePetitionId object (multiple key object generated by hibernate)

      ServiceServicePetitions object (the service to use in blazeDS)


      Flex 4 (All the objects generated by Flex Builder at the time of map the service)












      Normally I call the service and later I try to get the data using a CallResponder object to make the assignation lastresult = ServicePetition; except when I use a datagrid that automaticly use the CallResponser.lastresult as dataprovider, without any assignation (important, always work!)


      The fact is that when I try to make the assignation all works alright, I get all the data, I can work with those data, all goes perfect, but...when I make the second call, the assignation (callresponder.lastresult = ServicePetition) does not assign anything.


      This is the code of the assignation:



          private var respPs:CallResponder;
          private var servPs:ServiceServicePetitions;
          private var objPs:ServicePetition;
          // Call
          public function AprobarPS(ter:String,idps:String,sec:int)
            servPs = new ServicioVPeticionesServicio();
            respPs = new CallResponder();
            respPs.token = servPs.getPeticionServicio(ter,idps,sec);
          // Get the data
          private function getDatosPs(resultEvent:ResultEvent):void
            objPs = respPs.lastResult as VPeticionesServicio;
            switch (obj.petitionType) { // Here I have a null exception





      I make the debug with the blazeDS tools and all the responses and call statements is Ok, and the service return the data always, but Flex only works the first time per execution.


      If I assign all the data field by field from lastResult to ServicePetition all works properly always, the first call, the second call, etc., but if I want to make the assignment, object to object, only works 1 time.



      any ideas?


      best regards,