2 Replies Latest reply on Aug 14, 2006 9:22 AM by davidmedifit

    Passing variables to a CFC

    davidmedifit Level 1
      I have been trying, in vain, to pass a variable to a CFC, from Flex.

      To start, I am using Flex 2, CF 7.02, Multi-server (all local). I know the CFC call works - I use it to populate a datagrid. When I click on a grid item, I "set" a custom component (a form). The idea is that it wil get the details of the firm from the DB and display it. I know that the actual query works, and it populates the form, because I tested it using a hardcoded key in the query.

      Here is the code I am using:

      1) In the component: (note, _standby is the key - I have confirmed that it is getting passed to the component alright)
      [Bindable] private var _standby:int;
      public function set standbyID(value:int):void
      _standby = value;
      standbyDetails = getStandbyRequestDetails.getStandbyRequestDetails({_standby});

      2) The remote object:
      <mx:method name="getStandbyRequestDetails" result="handleStandbyResult(event)"

      3) And the CFC:
      <cffunction name="getStandbyRequestDetails" output="true" access="remote" returntype="query">
      <cfparam name="standbyid" type="numeric"/>
      <cfquery name="getStandbyRequestDetails" datasource="golf">
      select * from standby_Request inner join standbytype on
      standby_request.coverageType = standbytype.standbyTypeID
      where standby_request.standbyRequestID = #standbyid#

      <cfreturn getStandbyRequestDetails>

      I have tried various ways to do it, and had errors come back (all tell me the param in the CFC was expected, but not received)

      1) standbyDetails = getStandbyRequestDetails.getStandbyRequestDetails({_standby}); (like above)
      2) standbyDetails = getStandbyRequestDetails.getStandbyRequestDetails({standbyid:_standby}); (I read this in another post, but it could have been old - v1.5).
      3) I added (more out of desperation, than anything)
      <mx:Array id="standbyidarray">
      <mx:Text id="standbyid" text="1"/>

      Any help with this matter would be appreciated - I'm sure it's not nearly as difficult as I'm making it out to be.

      Sincerest thanks in advance.

        • 1. Re: Passing variables to a CFC
          Not sure if just my raw code will help, but here is my RM call:

          <mx:RemoteObject id="myService" destination="ColdFusion" source="CleantechCFC.CapitalSurvey" showBusyCursor="true">

          <mx:method name="getCompany" result="companyHandler(event)" fault="Alert.show(event.fault.message)"/>


          Now, I have a textArea field that send the value of that field everytime a change is made to the field:

          <mx:TextArea x="75" y="5" fontFamily="Arial" fontSize="12" color="#000000" width="300" height="20" id="cvcompanyName" editable="true" enabled="true" wordWrap="false" change="myService.getCompany(cvcompanyName.text)"/>

          Note the "change" at the end where I call myService.getCompany(cvcompanyName.text)

          Maybe the problem is the {} on your line:
          standbyDetails = getStandbyRequestDetails.getStandbyRequestDetails({_standby});

          Try removing them.
          • 2. Passing variables to a CFC
            davidmedifit Level 1
            Hi Mich,
            Thanks for your help - That seeemd to work. Also, (I'm such a clutz!) I started using <cfargument> in my CFC, instead of <CFPARAM> to accept the parameter, like I should have been doing! Thanks for your help with this.