2 Replies Latest reply on Jun 24, 2009 7:31 AM by LinkMc

    How do I return data back to Flex from my cfc

    LinkMc Level 1

      I am using a Default cfc CRUD built in Flex Builder 3 using activeRecord. I have changed my cfc to return query and access to remote, but I still get event.result = null.

       

      What am I doing wrong? I want to simply return the record after I save it.

       

      I know I could create a new method in my handler to call a query that will get the record based on my form values, but I want to return that same value without having to do that in one shot. Is this possible?

       

       

      Flex MXML

       

       

      <mx:RemoteObject

      id="roMyObject" destination="ColdFusion" source="cfc.MyGateway" showBusyCursor="true">

       

      <mx:method name="save" result="MyHandler(event);"/>

       

      </mx:RemoteObject>

       

       

       

       

      CFC Gateway

       

      <cffunction name="save" output="false" access="remote">

      <cfargument name="obj" required="true" />

      <cfreturn obj.save() />

      </cffunction>

       

       

      CFC

       

      <cffunction name="save" output="false" access="public" returntype="void">

       

           <cfscript>

       

           if(this.getClassifiedID() eq 0)

           {

       

           create();

       

           } else {

       

           update();

       

           }

       

           </cfscript>

       

      </cffunction>

       

       

      <cffunction name="create" output="false" access="remote" returntype="query">

       

           <cfargument name="obj" required="true">

           <cfset var qCreate="">

           <cfset var qRead="">

       

           <cftransaction isolation="read_committed">

       

       

                <cfquery name="qCreate">

                Create record

                </cfquery>

       

       

                <cfquery name="qGetID" >

                select last_insert_id() as new_id;

       

                </cfquery>

       

           </cftransaction>

       

       

      <cfreturn qGetID>

       

      </cffunction>