0 Replies Latest reply on Mar 23, 2010 1:32 AM by didci

    Connect FLEX with Coldfusion component

    didci

      Hello

       

      I have a big problem finding out all the step i need to do so to connect flex with coldfusion component.

      In theory i know how, because i read much it, but in the end it doesn't get/send the data from/to the cfc (coldfusion component).

      I am using Flex Builder 3, Coldfusion 8, Actionscript 2.

      Can anyone please show me all the steps.

       

      I think i have to use something like this to connect with the cfc:

       

      <mx:RemoteObject id="usersCFC"  endpoint="http://127.0.0.1/flashservices/gateway
           source="myappdir.components.mycfc"   showBusyCursor="true">

           <mx:method name="getAllUsers" 
                result="userResultHandler(event.result) 
                fault="userFaultHandler(event.fault)"/>

      </mx:RemoteObject>

       

      But it doesn't work.

       

       

      Up till now, i was making this connection in the cfm file so to call some coldfusion function in this way:

       

      public function SetName():Void{
                                  <cfoutput>
                                  //create connection
                                  var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
                                  //declare service
                                  var myService:mx.remoting.NetServiceProxy;
                                  </cfoutput>
                                 
                                  //make an object that will handle the response
                                  var responseHandler = {};
                             
                                  //put the controls in scope to avoid calling _root
                                  var AlarmNameSelect = AlarmNameSelect;
                                 
                                  //function that receives the response
                                  responseHandler.onResult = function( results: Object ):Void {
                                      //when results are back, we show the text received
                                                       
                                      AlarmNameSelect.dataProvider = results;
                                                                      
                                      mx.managers.CursorManager.removeBusyCursor();          
                                  }
                                
                                  //function that receives any error that may have occurred during the call
                                  responseHandler.onStatus  = function( stat: Object ):Void {
                                      //if there is any error, show an alert
                                      alert("Error while calling cfc:" + stat.description);
                                      mx.managers.CursorManager.removeBusyCursor();
                                  }
                     
                                  //get service. First parameter is path to component and
                                  //the second it's the object that will handle the response
                                  myService = connection.getService("components.alarm_createComponent", responseHandler );
                                  mx.managers.CursorManager.setBusyCursor();
                                  //make call
                                 
                                 myService.SetName(MainTypeSelect.value,<cfoutput>#session.paypart#</cfoutput>);

                               //SetName is the name of the function in the coldfusion component.
                                 
                              }

       

      Should i set something somewhere on the server and what and where, please help me, i really need to start this working :/

       

      Thank you very much in advance!

       

      Kind regards!