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
      </query>
      <cfreturn Brands>
      </cffunction>
        • 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
              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()">
              <mx:Script>
              <![CDATA[
              import mx.rpc.events.ResultEvent;
              import mx.controls.Alert;
              import mx.collections.ArrayCollection;

              [Bindable]
              public var myCustomers:ArrayCollection;

              // initialize application
              public function initApp():void {
              ro.GetCustomers();
              }
              //populate myCustomers arraycollection
              public function handleCustomerResult(event:ResultEvent):void {
              myCustomers=event.result as ArrayCollection;
              }
              ]]>
              </mx:Script>

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

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

              </mx:Application>
              • 4. Re: RemoteObject and ComboBox
                Andrew_Lattimore
                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]"/>

                </mx:Application>

                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.