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

    Database

    vasibe
      Hi
      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.

      Thanks
      Vasibe
        • 1. Re: Database
          CathyM
          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
            aBill
            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
            Example:
            <?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"/>
            <mx:Script>
            <![CDATA[
            private function setup():void
            {
            ro.echoObjects([{label:"MA",value:"Massecussetts"},{label:"NY",value:"New York"}]);
            }
            ]]>
            </mx:Script>
            <mx:ComboBox dataProvider="{ro.echoObjects.lastResult}" labelField="value"/>
            </mx:Application>

            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
              hi,
              thanks william and cathy .now its working.

              Vasibe