3 Replies Latest reply on Aug 18, 2006 3:45 AM by vasibe


      i am having one issue.right now we are developing a shopping cart.in that application i need to populate the values from the database in the combobox(Getting the values from the databases and set in the combobox).
      i have succeeded in connecting the flex application to the database but i dont know how to get the values from the database to the<mx:combobox> and i need a code for that.

        • 1. Re: Database
          You'll want to create a Java object which exposes a method to get the values from the database. From mxml, you'll use the RemoteObject tag to call that method on the server. The result handler for the RemoteObject will bind the values of the result to the <mx:combobox> tag.

          Please see the documentation for using the RemoteObject tag.
          • 2. Database
            As Cathy said, you should able to find a good documentation from the remoteobject & combobox tag. combobox takes array of objects as dataprovider. You can specify the field which you want to use by specifying it in the labelField attribute
            <?xml version="1.0"?>

            <mx:Application width='800' height='800' xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="setup()">
            <mx:RemoteObject destination="qa.echoservice.Echo" id="ro"/>
            private function setup():void
            ro.echoObjects([{label:"MA",value:"Massecussetts"},{label:"NY",value:"New York"}]);
            <mx:ComboBox dataProvider="{ro.echoObjects.lastResult}" labelField="value"/>

            By removing the labelField="value", combobox shows MA,NY. Otherwise, combobox use value field . You should see Massachusetts, New York in the box

            Please look it up from the doc for more details

            Hope it help!
            William Chan
            • 3. Re: Database
              vasibe Level 1
              thanks william and cathy .now its working.