1 Reply Latest reply on Feb 27, 2008 10:16 AM by m_hartnett

    Combo Box to display selected value on return

      I am having some trouble trying to figure out how to poplulate my combo box with the selected value from the db. Can anyone help me with this. I can populate my combo box just fine its just coming back into the application I can't populated it with the selected value I need

      prompt="Select One"
      change="model.currentCaseVO.occurenceCode = occurenceCode.selectedItem.data"
      width="100%" height="19"/>
        • 1. Re: Combo Box to display selected value on return
          m_hartnett Level 3
          Here is an article that I used to create a value aware combo box:

          There are a number of value aware combobox implementations and articles out there however I found this article very good. Also read the comments as they point out some bug fixes and enhancements.

          Here is my code. This is a custom combobox object that will extend the flex combobox and be used in place of the flex combobox.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:ComboBox xmlns:mx=" http://www.adobe.com/2006/mxml">

          import mx.collections.ArrayCollection;
          private var candidateValue:Object;
          private var valueDirty:Boolean = false;
          private var candidateDataProvider:Object;
          private var dataProviderDirty:Boolean = false;

          private function applyValue(val:Object):void {
          if ((val != null) && (dataProvider != null)) {

          for (var i : int = 0; i < dataProvider.length; i++) {
          if ( dataProvider != null && (val == dataProvider.data || val == dataProvider .label)) {
          ; selectedIndex = i;
          ; return;
          } } }
          selectedIndex = -1;
          } public function set value(val:Object) : void {
          candidateValue = val;
          valueDirty = true;
          override public function set dataProvider(value:Object):void {
          candidateDataProvider = value;
          dataProviderDirty = true;

          override protected function commitProperties():void {

          if (dataProviderDirty) {
          super.dataProvider = candidateDataProvider;
          dataProviderDirty = false;

          if (valueDirty) {
          valueDirty = false;


          In order to use this you must put something like the following in your container:
          This points to where the custom component will be located.

          Your combobox tag should now be defined as following:
          <viewUtil:ComboBox id="locationId"
          value="{ model.activeObjectO.direction.locationId}"

          you obviously need to substitute the dataprovider, change and value property values.