1 Reply Latest reply on Sep 30, 2006 2:12 PM by peterent

    AMF and combo box

    Ronsweb Level 1
      I am having a difficult time trying to pull data from an CFC and output the data in a combo box using AMF. Here is the code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      backgroundGradientColors="[#277DC6, #50ABF7]" width="800" height="600" creationComplete="InitApp();">
      <mx:RemoteObject id="myService" destination="ColdFusion"
      fault="Alert.show(event.fault.faultString), 'Error'" source="cguidesystem.curriculumguides" >


      </mx:RemoteObject>

      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;
      public function InitApp():void{
      myService.qacademicyears();
      }

      ]]>
      </mx:Script>
      <mx:states>
      <mx:State name="displaydata">

      <mx:AddChild relativeTo="{panel1}" position="lastChild">
      <mx:Button x="231" y="125" label="Close Grid" click="currentState=''"/>
      </mx:AddChild>
      </mx:State>
      </mx:states>
      <mx:Panel x="108.5" y="25" width="583" height="435" layout="absolute" cornerRadius="12" borderColor="#007cf9" id="panel1">
      <mx:Button x="39" y="39" label="Add New Academic Year" width="150"/>

      <!-- This is the combo box that I am trying to provide data to. -->
      <mx:ComboBox x="304" y="39" dataProvider="{myService.qacademicyears.result}" />
      </mx:Panel>
      </mx:Application>

      ------------------------------------------------------------------------------------------ --------------------
      Here is the CFC:
      <cfcomponent>

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

      <CFQUERY NAME="qacademicyears" DATASOURCE="admissions">
      SELECT *
      FROM tbl_academic_year
      </CFQUERY>
      <cfreturn qacademicyears>
      </cffunction>

      </cfcomponent>

      Any help is appreciated.


      Ron

        • 1. Re: AMF and combo box
          peterent Level 2
          First off, are you certain the cffunction is returning anything? If not, you can either use a network sniffer or use a result event handler on the RemoteObject. Using a result event handler you can set a break-point or use a trace statement or output the contents of the result to a TextArea - anything to let you know what are getting from the cffunction call.

          If you are getting something, then try using {myService.qacademicyears.lastResult}" for the dataProvider. The ComboBox is expecting the dataProvider to have either simple elements (eg, Strings) or if Objects, each Object to have a property named "label". If you have Objects, but no label property, then add labelField= to the ComboBox and specify the name of the property you want to show up in the ComboBox dropdown.