3 Replies Latest reply on Oct 3, 2006 6:45 AM by nyfeman

    Remoting

    Rob M Love
      Hello All,

      Please help. I've seen various examples of remoting between CF and FLEX and however the examples I can get to work don't seem to apply when I substitute my own practice project and data they all fail.
      Is there a very Gerberfied example that would show the start to finish and all the steps in between? I preferably would like the see it start at the cfc wizard and then what options were chosen and why. Then on to writing the call to the cfc and the action script to populate a datagrid.
        • 1. Re: Remoting
          nyfeman Level 1
          Maalox --

          If you are NOT an experienced programmer, you might want to avoid the wizard at first for understanding how the Remote Object works.

          I created a simple project using the wizard and honestly, not being a hardcore programmer, I was astounded by the complexity of what it created.

          I started without the wizard just by doing a lot of research on RemoteObject and cfcs in the documentation. Now that I know the basics of the mechanics, I can look at a wizard created project and "reverse engineer" more effectively.

          Here's some code to look at. It just goes to ColdFusion queries the database and returns the results to a datagrid. It's about as simple as they come.
          cfc (testEvent.cfc):
          <cfcomponent name="testEvent">
          <cffunction name="qryEventData" access="remote" returnType="query">
          <cfquery datasource="Roster" name="qryEvent" debug="yes">
          SELECT * FROM tblEvents
          </cfquery>
          <cfreturn qryEvent>
          </cffunction>
          </cfcomponent>

          mxml:
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
          <mx:Script>
          <![CDATA[
          import mx.controls.Alert;
          import mx.rpc.events.*;
          import mx.collections.ArrayCollection;

          [Bindable]
          public var qryResult:ArrayCollection = null;
          public function initApp():void{
          svc.qryEventData();
          }
          public function resultHandler(event:ResultEvent):void{
          qryResult = event.result as ArrayCollection;
          }
          ]]>
          </mx:Script>
          <mx:RemoteObject id="svc" destination="ColdFusion" source="testEvent"
          result="resultHandler(event)" fault="(Alert.show(event.fault.message))"
          showBusyCursor="true"/>
          <mx:Panel x="0" y="65" width="100%" height="346" layout="absolute" title="Tester">
          <mx:DataGrid id="eventGrid" dataProvider="{qryResult}"/>
          </mx:Panel>
          </mx:Application>
          • 2. Re: Remoting
            Rob M Love Level 1
            Thanks, I've recreated the code and supplied my own cfc and data calls so I have on question.

            Where do you have your cfc locatd in relation to the source=""?
            • 3. Re: Remoting
              nyfeman Level 1
              Right now, the cfc is at the root level and the swf is up a few directories, actually.

              So it's
              www.foo.com/testEvent.cfc
              and
              www.foo.com/someDir/otherDir/tester.html