3 Replies Latest reply on May 14, 2009 7:12 AM by Cr99

    Combobox dataprovider problems with HTTPService

    Cr99 Level 1

      I have comboboxes all throughout my application and up til now, they have worked fine with my other HTTPService calls, but for some reason one of them has a bug now that I just can't seem to figure out.


      Here's the data it is getting sent from the servlet:














      And here are my HTTPService and Combobox definitions.


      <mx:HTTPService id="chartTypeOptions" useProxy="false" method="GET" url="{dbURL}"/>

      <mx:ComboBox id="axisType" dataProvider="{chartTypeOptions.lastResult.system.data}" labelField="name"/>


      But the items in my combobox are messed up.  This is what they look like:


      [object Object]





      Why is it sticking the [object Object] at the top?  I know my chartTypeOptions only has three elements.  I've tried lots of different things to get this cleared up but so far I've not been able to fix this.  Any help would be greatly appreciated.

        • 1. Re: Combobox dataprovider problems with HTTPService
          Gregory Lafrance Level 6

          I've heard using lastResult can cause problems and it is always better to use a result handler. I never use lastResult.

          • 2. Re: Combobox dataprovider problems with HTTPService
            Gregory Lafrance Level 6

            Example of using resultHandler.


            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  import mx.rpc.events.ResultEvent;
                  import mx.collections.XMLListCollection;
                  [Bindable] private var statesXLC:XMLListCollection;
                  private function statesHandler(evt:ResultEvent):void{
                    statesXLC = new XMLListCollection(evt.result.state as XMLList);
              <mx:HTTPService id="statesSrvc" result="statesHandler(event)"
                resultFormat="e4x" url="states.xml"/>
              <mx:ComboBox id="statesCbx" dataProvider="{statesXLC}" 
                labelField="@name" fontSize="14"/>
                <mx:FormHeading label="State Information" fontSize="16"/>
                <mx:FormItem label="State:" fontSize="12" fontWeight="bold">
                  <mx:Label fontSize="12" 
                <mx:FormItem label="Statehood:" fontSize="12" fontWeight="bold">
                  <mx:Label fontSize="12" 
                <mx:FormItem label="Capital:" fontSize="12" fontWeight="bold">
                  <mx:Label fontSize="12"



            ------------------ cities.xml -----------------

            <?xml version="1.0" encoding="utf-8"?>
                <state name="Alabama" statehood="1819" capital="Montgomery"/>
                <state name="Alaska" statehood="1959" capital="Juneau"/>
                <state name="Arizona" statehood="1912" capital="Phoenix"/>
                <state name="Arkansas" statehood="1836" capital="Little Rock"/>
                <state name="California" statehood="1850" capital="Sacramento"/>
                <state name="Colorado" statehood="1876" capital="Denver"/>
                <state name="Connecticut" statehood="1788" capital="Hartford"/>
                <state name="Delaware" statehood="1787" capital="Dover"/>
            1 person found this helpful
            • 3. Re: Combobox dataprovider problems with HTTPService
              Cr99 Level 1

              Thanks for the help.  I had tried using a result handler before but that didn't work.  However I finally tracked down the problem.  I had a section of the code called after the combobox got populated:


              axisType.selectedItem = someInvalidString;


              Since it couldn't find a match, it set the selection to [object Object] instead!  So this was just me shooting myself in the foot.  But it sure was hard to track down...