1 Reply Latest reply on Aug 17, 2012 3:09 PM by WebolutionDesigns

    Populating ComboBox with CFC web service return type query

    WebolutionDesigns Level 1

      I am just now learning Flex and am attempting my first app (I have been a CFer for years).


      Anyway, I am attempting to build an AIR app in Flex that simply has a login with a form to submit information into a database.


      Things are going ok, except I am stumped at something that I think should be simple...populating a combo box. I have a CFC (I am using CFCs as a web service to drive the app) that contains a method that simply returns a query. I want to use the results to populate the combo box display and value. I created the combo box and then dragged the method to the box to have FB create the code. It populates the list but with just [object Object]. This is a piece of cake in CF but I am not stumbling across the correct syntax in Flex. Any pointers would be appreciated.


      Here is my current code.


      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"











                  import mx.collections.ArrayCollection;

                  import mx.controls.Alert;

                  import mx.events.FlexEvent;

                  import mx.rpc.events.FaultEvent;

                  import mx.rpc.events.ResultEvent;

                  import mx.utils.ObjectUtil;


                  /*Login Code----------------------------------*/

                  private var loginrs:Object;


                  //Failed to connect to the wsdl service

                  private function GeneralFailed_Handler(e:FaultEvent):void


                      Alert.show(e.fault.faultString, "Error connecting to the service");


                  //Login Handler

                  protected function submitBtn_clickHandler(event:MouseEvent):void


                      loginUserResult.token = users.loginUser(userName.text, password.text);


                  //Result Handler for Account Authentication

                  private function loginUserResult_resultHandler(e:ResultEvent):void


                      //check the result

                      //Alert.show(ObjectUtil.toString(e.result),"Login Results")

                      loginrs = new Object();

                      loginrs = e.result;


                      if(loginrs['loggedin'] == 'Y')


                          currentState = 'insertInventory';


                          Alert.show("Try Again Please.");





                  /*VIN Lookup Code----------------------------------*/

                  private var vinrs:Object;


                  //VIN Lookup Handler

                  protected function VINSubmitbtn_clickHandler(event:MouseEvent):void


                      getvinInfoResult.token = vinlookup.getvinInfo(vin.text, "BASIC");


                  //Result Handler for Account Authentication

                  private function vinLookupResult_resultHandler(e:ResultEvent):void


                      //check the result

                      Alert.show(ObjectUtil.toString(e.result),"Lookup Results")

                      vinrs = new Object();

                      vinrs = e.result;


                      if(vinrs == null)


                          Alert.show("The VIN did not decode. Try Again Please.");




                          bodyStyle.text = vinrs['VARBODYSTYLE'];







                  /*Item Type Combo Box Code----------------------------------*/   

                  protected function comboBox_creationCompleteHandler(event:FlexEvent):void


                      getItemtypeResult.token = inventory.getItemtype();








              <s:State name="login"/>

              <s:State name="insertInventory"/>




              <s:CallResponder id="loginUserResult" result="loginUserResult_resultHandler(event)"/>

              <users:Users id="users" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

              <s:CallResponder id="getvinInfoResult" result="vinLookupResult_resultHandler(event)"/>

              <vinlookup:Vinlookup id="vinlookup" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

              <inventory:Inventory id="inventory" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

              <s:CallResponder id="getItemtypeResult"/>

              <!-- Place non-visual elements (e.g., services, value objects) here -->


          <s:Panel width="250" height="150" title="Login" horizontalCenter="0" verticalCenter="0" includeIn="login">

              <mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">

                  <mx:FormItem label="User Name">

                      <s:TextInput id="userName"/>


                  <mx:FormItem label="Password">

                      <s:TextInput id="password" displayAsPassword="true"/>



                      <s:Button label="Login" id="submitBtn" click="submitBtn_clickHandler(event)"/>




          <s:Panel includeIn="insertInventory" width="400" height="400" title="Insert Inventory" horizontalCenter="0" verticalCenter="0">

              <mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">

                  <mx:FormItem label="VIN">

                      <s:TextInput id="vin"/>


                  <mx:FormItem id="vinSubmitbtn">

                      <s:Button label="Decode VIN" id="VINSubmitbtn" click="VINSubmitbtn_clickHandler(event)"/>


                  <mx:FormItem label="Body Style">

                      <s:TextInput id="bodyStyle"/>


                  <mx:FormItem label="Item Type">

                      <s:ComboBox id="comboBox" creationComplete="comboBox_creationCompleteHandler(event)">

                          <s:AsyncListView list="{getItemtypeResult.lastResult}"/>