4 Replies Latest reply on Nov 30, 2006 4:10 PM by Andrew_Lattimore

    RemoteObject and ComboBox

    GeorgeWS Level 1
      I am having trouble filling in a combobox with my remoteobject. Im thinking I need to retrieve the RO into an ArrayCollection. but im not sure how this would look. Can someone show me a sample? In my app if I hard code an array with data and labels it works fine.

      I have a RO like:

      <mx:RemoteObject id="Brands" destination"COLDFUSION" source="Inv" showBusyCursor="true"/>

      I have a ComboBox:

      <mx:comboBox id='brandfilter' dataprovider="{Brands.Brands.data}"/>

      I have a CFC:

      <cffunction name="Brands" access="remote" returnType="query" output="false">
      <cfquery name="Brands" datasource="myDatasource">
      Select distinct brandid as data , branddesc as label
      From Inv
      <cfreturn Brands>
        • 1. Re: RemoteObject and ComboBox
          kruse Level 1
          I think that the combobox takes an array.
          Try to return the data in an array insted of a query.
          • 2. Re: RemoteObject and ComboBox
            GeorgeWS Level 1
            I like your idea because I have this working if I dont use the remote object and fill the ComboBox with a hard coded array. How do I get my RemoteObject into an array. I have been trying ArrayCollection but I must be missing something.
            • 3. Re: RemoteObject and ComboBox
              Jason.McKinney Level 1
              Just put this together for my app, this is how I did it.

              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initApp()">
              import mx.rpc.events.ResultEvent;
              import mx.controls.Alert;
              import mx.collections.ArrayCollection;

              public var myCustomers:ArrayCollection;

              // initialize application
              public function initApp():void {
              //populate myCustomers arraycollection
              public function handleCustomerResult(event:ResultEvent):void {
              myCustomers=event.result as ArrayCollection;

              <mx:RemoteObject id="ro" destination="ColdFusion" source="CustomerGateway" showBusyCursor="true">
              <mx:method name="GetCustomers" result="handleCustomerResult(event)" fault="Alert.show(event.fault.message)"/>

              <mx:ComboBox id="cboCustomers" dataProvider="{myCustomers}" labelField="customer_name"/>

              • 4. Re: RemoteObject and ComboBox
                If you use the mx:WebService you can use a query to specify the labelField attribute in the ComboBox. It could look something like this:

                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="[webservice id].[component function name].send()">

                <mx:WebService id="[webservice name]" wsdl="[http path to cfc.wsdl]" />

                <mx:ComboBox id="[ComboBox name]" dataProvider="{[webservice id].[component function name].lastResult}" labelField="[column name]"/>


                You must ensure that the access="remote" in your cfc function to access the data. I'm not sure what the implications are of doing this but I tried it and it worked for me.