Fill ComboBox programmatically by a method

I'm trying to populate a combobox in a method. However my drop-down list box is empty. Is there a way to update the dataProvider of the combobox?

Here is my code,

Thank you

---------------------------

<? XML version = "1.0" encoding = "utf-8"? >
< mx:Application
' xmlns:mx = ' http://www.Adobe.com/2006/MXML "
styleName = "plain".
Initialize = "init ()" >

< mx:Script >
<! [CDATA]

Import mx.controls.Alert;
Import mx.rpc.AsyncResponder;
Import mx.collections.ArrayCollection;

[Bindable]
public var myArray:Array;

private function init (): void
{

myArray.push ("one");
myArray.push ("two");

}
[]] >
< / mx:Script >


< mx:ComboBox id = "QueryComboBox" dataProvider = "{myArray}" / >

< / mx:Application >

You must use an ArrayCollection collection for the dataProvider:

var myAC:ArrayCollection = new ArrayCollection (myArray);

If this post answers your question or assistance, please mark it as such.

Greg Lafrance - Flex 2 and 3 certified ACE

www.ChikaraDev.com

Flex / development, training, AIR and Support Services

Tags: Flex

Similar Questions

  • Fill listbox programmatically in ADF

    Hello

    This my code for listbox on my jsf page.

    < af:selectOneListbox id = value = "#{backingBeanScope.RegWoComp.selectedItem"lstcatg"}" >

    < af:selectItem id = value = "#{backingBeanScope.RegWoComp.selectItems"lstselect"}" / > "

    < / af:selectOneListbox >

    and my code to populate the listbox control

    public String commandLink_action() {}

    Add the code in the event here...

    System.out.println ("image clicked");

    If (selectItems == null) {}

    System.out.println ("Method1");

    selectItems = new ArrayList();

    selectItems.add (new SelectItem(1,"abcd"));

    selectItems.add (new SelectItem ("Value2", "label2"));

    selectItems.add (new SelectItem ("Value3", "label3"));

    }

    Returns a null value.

    }

    private String selectedItem;

    private list selectItems;

    public String getSelectedItem() {}

    System.out.println ("GetSelectedItem");

    return the selectedItem;

    }

    {} public void setSelectedItem (String selectedItem)

    System.out.println ("setselecteditem");

    this.selectedItem = selectedItem;

    }

    public list getSelectItems() {}

    System.out.println ("Method");

    selectItems return;

    }

    in fact, I want to fill on the command button click event.

    Will there be any error in the newspaper?

    Why do you use scope of backing bean?

    use like this-

    and why are you using af:selectItem? If you have not enabled the shared above link?

    Use instead of like this-

      

    For more details - Blog of Ashish Awasthi (Jdev/ADF): fill the values programmatically in a body af:selectOneChoice ADF

    Ashish

  • Fill combobox with multiline field

    Is it possible to get a picture of a multiline text field and put this table in a ComboBox?

    I think I should use the split() function, but I don't know how to do this.

    I'm trying to find an easy way to populate a combobox control.

    This topic shows how you can split the value of the value of a field text multiline in carriage returns: http://forums.adobe.com/thread/789976

    You can then use the field setItems method to fill the list box with items area: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.752.html

  • Using HTTPService to fill Combobox from DB SQL

    I'm having a little problem with the filling of a combobox after I call a httpservice. Showing data, however, it's all appear on a single line over several items to combobox. For example, I get a single line in the drop-down menu that looks like this:

    DATE1, DATE2, DATE3

    instead of get:

    DATE1
    DATE2
    DATE3

    I found this article, but it does not really my problem and I already seem to wear all recommended in this article ( http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60 & catid = 585 & threadid = 1220768 & highlight_key = y & keyword1 = combobox).

    Part of my PHP script:
    -----------------------------------------------
    $return = '< horodateurs > ';
    While ($Row = mysql_fetch_array ($result))
    {
    $qrtrdisp is $row ["quarter"];.
    $return. = "< date >." $qrtrdisp. "< / date > ';
    }
    $return. = ' < / timestamps > ';
    Print ($Return);
    -----------------------------------------------

    Part of my MXML file:
    -----------------------------------------------
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "absolute" creationComplete = "getDates.send ()" >

    <!-set call to enter the dates for the shape->
    < mx:HTTPService id = "getDates" url = "https://url/file.php" useProxy = "false" method = "GET" showBusyCursor = "true" >
    < / mx:HTTPService >

    < mx:ComboBox id = "dates" x = "201" y = "6" dataProvider = "{getDates.lastResult.timestamps}" labelField = 'date' > < / mx:ComboBox > ""
    -----------------------------------------------

    Any help would be greatly appreciated.

    Thank you
    Chris

    You may need to structure xml youre differently. You set the dataprovider for the timestamps down, try each date in its own node parent and dot up to getDates.LastResult.timestamps of packaging. (the new node)

  • Clear/fill ComboBox in a Subvi?

    I am building an app with 6-8 pulldown ComboBoxes and each of them will be erased and then first met based on a file.  I wrote a small vi to do exactly what I want, but I can't understand how to pass the PropertyNode[tringsAndValues] each ComboBox to the Subvi?  I wouldn't really have to reproduce this code 6 - 8 times in my main VI.

    The first thing I noticed is that my original small VI used the Structure of sequence flat to make sure I have everything first empty the ComboBox and then fill - LabView wouldn't even accept this as a sub - VI when I tried to add to my main VI, so I'm breaking the clearing in 1 Subvi and filling in another.  I tried first to setup the VI of compensation which is when I noticed that I had found no original way of referencing ComboBox in my Subvi.

    Anyone with ideas?

    Steve

    Create a reference to one of the terminals of the combobox, and then create a control from this reference.  cut and paste the control in the Sub - VI and use it as a control for the reference in the Subvi.

    are you use create-> node-> (property) property?  It's less useful: search the antiderivative of regular property node in the application control pane

    Here's what they look like:

    Once your Subvi accepts a ref of the comboBox, you can put your combobox 6 to 8 refs in an array and then call your subVIs a for loop.

    B

  • Fill the programmatic view object during execution

    Hi all

    I have a requirement to switch between the three different data source during execution in a single page. The user interface and the field names are the same for these three cases, but data from various sources (queries).

    So, imagine that we have 3 objects in view which has implemented read-only (object request depending on the view) and we want to fill a display object at the main performance as a data source for my page.

    My idea is to use "Prgorammatic view object" for this data source and then fill dynamically the contents of one of the three objects view read-only based on a setting in the user's selection.

    First of all, I want to know if it is thin approach and if yes, then get some points on the implementation or any other sample.

    I found this example:

    http://techiecook.WordPress.com/2011/05/17/programmatically-populate-view-objects-in-Oracle-ADF/

    Thanks in advance,

    Nasser

    Hello

    It is more a case of use for Adaptive connections. See:https://blogs.oracle.com/groundside/entry/towards_ultra_reusability_for_adf

    You can use EL to change the name of the ViewObject that an iterator in ADF queries its data. If the switch is on the link layer and there is no need for programmatic view objects. Unlike in the article of the blog above, VO 3 exist in your case then you don't need to create on the fly. Just change the name of VO in the managed bean referenced

    Frank

  • Programmatically access the method of service (customer interface)

    Hello

    I work with JDeveloper 11.1.1.6.0. I exposed an ApplicationModule method in the client interface.
    I know I can drag and drop on my view and work with it. But how to access these programmatic method?
    Can I use the bindings, y at - it a "best practice way"?

    Thanks in advance.
    Alex

    Check [url https://blogs.oracle.com/jdevotnharvest/entry/best_practice_invoking_business_services] best practices invoking business services methods from JSF beans

  • Fill ComboBox with external data

    I have this drop-down list box:

    < mx:ComboBox change = "changeEvt (event)" x = "134" y = "48" > "
    < mx:Array >
    < mx:Object label = 'AM' data = 'ALL' / >
    < mx:Object label = "BM" data = "CM" / >
    < mx:Object label = "CM" data = "FROM" / >
    < / mx:Array >
    < / mx:ComboBox >

    I would like to do this fill a XML file, for example I import

    < empTypes >
    < laborClass lc = 'AM' <>/.
    < laborClass lc = 'BM' <>/.
    < laborClass lc = 'CM' <>/.
    < / empTypes >

    .. .in an XMLList, named said "empTypes" what is the syntax I use for this insert in the comboBox? I don't know how to do so that he can enter.

    M.

    I changed it to filter1=event.currentTarget.selectedItem.@lc; and that the time seems to work :)

  • Fill Combobox with nested XML

    Hello!
    How can I fill a ComboBox with an XML retrieved via a HTTPService?

    My XML looks like

    <? XML version = "1.0" encoding = "iso-8859-1? >
    < xml >
    < node label = value '1' = 'a' / >
    < node label = value "2" = "b" >
    < node label = "21" value = "ba" / >
    < node label = '22' value = 'bb' / >
    < node label = "23" value = "bc" / >
    < / node >
    < node label = '3' value = 'c' / >
    < node label = "4" value = "d" / >
    < node label = '5' value = 'e' / >
    < / xml >

    The output you want in the drop-down list would be

    one
    b
    -ba
    -bb
    Colombia-British
    c
    d
    e

    < mx:ComboBox id = "selectedLevel" dataProvider = labelField 'structure of {}"="label"/ >

    'structure' is an XMLListcollection, looks like my Resulthandler

    structure = new XMLListCollection (event.result.node);


    Can someone give me a hint what is missing?

    Thank you.

  • fill combobox via rpc and arraycollection collection

    Hello

    I have this XML coming via httpservice.

    < types >
    < type >
    < TypeId > 1 < / TypeId >
    < TypeUitspraak > Vonnis < / TypeUitspraak >
    < / type >
    < type >
    < > 2 TypeId < / TypeId >
    Arrest of < TypeUitspraak > < / TypeUitspraak >
    < / type >
    < / types >

    Here's (part of) the code

    Import mx.collections.ArrayCollection;
    Mx.rpc.events import. *;


    [Bindable]
    private var uitspraakTypes:ArrayCollection;

    private void typesHandler(event:ResultEvent):void {}
    uitspraakTypes = event.result.types.Type;
    }


    private function InitApp (): void
    {
    types. Send();
    }


    "" < mx:HTTPService id = 'types' url = ' http://www.emis.vito.be/SBO/haaltypes.asp ' result = "typesHandler (event)" / >

    < mx:ComboBox id = "typeUitspraak" dataProvider = "{uitspraakTypes}" > < / mx:ComboBox >


    in debugging mode in that I can see the arraycollection collection correctly filled
    I want to bind TypeUitspraak node of the xml to a combobox.
    I get [object Object] in my combobox.

    Please tell me what I'm missing here.

    Thank you

    Karel

    Hello
    You ares is simply not enough the only important thing

    ComboBox uses a property called labelfield to show your domain, you must pass a dataprovider and your arraycollection collection a labelfield, in your case TypeUitspraak of penny

  • fill combobox to an xml file

    I'm trying to fill a combobox with data from an xml file, this is supposed to be a simple right to face, but for some reason I can't get it to work. That's what I do:

    I found a solution!

    I don't understand the logic behind it, but it works!

    "I removed the dataProvider ="{cbData}"and labelField="@label "attributes of the

    private void lookUpDataHandler(evt:ResultEvent):void {}
    denomination.labelField = "label";
    denomination.dataProvider = evt.result.allrows.singlerow;
    }

    I someone can explain the reason why the previous code does not work, please do so.

  • Fill ComboBox with XML data

    I would like to fill a ComboBox with data in a simple xml file like this. It's probably quite newbie question, but I couldn't find the answer to the search in this forum and the documentation up to date.


    < root >
    option 1 < item > < / item >
    option2 < item > < / item >
    Option3 < item > < / item >
    < / root >


    I would be very grateful if someone tell me how the ComboBox control to retrieve data from XML file. Thank you!

    I found a way to do it. Here is the code I use to populate a ComboBox control with dynamically loaded XML data (the XML content is in the first post).
    I'm sorry that I have opened a topic for this fundamental question. In any case I hope that the thread is useful for someone. If you think that there is something wrong with the code below, please post a reply.



    http://www.Adobe.com/2006/mxml"creationComplete ="parseXML (); » >


    public var myXML:XML
    public var myLoader:URLLoader

    function parseXML (): void {}
    myXML = new XML();
    var XML_URL:String = 'content.xml ';
    var myXMLURL:URLRequest = new URLRequest (XML_URL);
    myLoader = new URLLoader (myXMLURL);
    myLoader.addEventListener ("complete", xmlLoaded);
    }

    function xmlLoaded(evtObj:Event):void {}
    myXML = XML (myLoader.data);
    combo.dataProvider = myXML.children ();
    }

    ]]>




  • Fill ComboBoxes with some Date Formats

    Hello, I need to show the day, month and year in three separate ComboBoxes for my project. Is it possible to combine and concentrate all ComboBoxes together?  For example, I want to get all the values for the Date of the birth of three days of combo boxes, month and year.

    Can someone help me please?

    If you want your users to select date, month and year of your 3 comboboxes?  If so, you can use the following syntax and access the properties of the 3 comboboxes selectedLabel:

    Import fl.data.DataProvider;

    import flash.events.Event;

    var month is ["jan", "feb", "mar", "Apr", '' may '', "jun", "Jul", "aug", "sep", "oct", "nov", "December"];.

    var dp:DataProvider = new DataProvider (monthA);

    monthCB.dataProvider = dp;

    var dataA:Array = [];

    setDatesF (31);

    function setDatesF(n:int):void {}

    for (var i: int = 1; i<=n; i++)="">

    dataA.push (i);

    }

    DP = new DataProvider (dataA);

    dateCB.dataProvider = dp;

    }

    var yearA:Array = [];

    for (var i: int = 1900; I)<2100; i++)="">

    yearA.push (i);

    }

    DP = new DataProvider (year);

    yearCB.dataProvider = dp;

    monthCB.addEventListener (Event.CHANGE, monthF);

    function monthF(e:Event):void {}

    var d: Date = new Date (yearCB.selectedLabel, 1 + monthA.indexOf (monthCB.selectedLabel), 0);

    setDatesF (d.date);

    }

  • Fill ComboBox data RemoteObject

    Hi all

    I try to use RemoteObject to populate a combobox. Here is my purpose and value mxml code...

    // Value Object Class: dataVO.as
    package com.mycomp
    {
         [RemoteClass(alias="datavO")]
         [Bindable]
         public class dataVO {
              public var data_id:int;
              public var data_name:String;
              public var data_type:String;
         }
    }
    
    // ActionScript code
    private
    function getAuthors(event:Event):void
    {
         // setup the remoteobject here

         serviceRO.getData.addEventListener(ResultEvent.RESULT, resultListener);
    }
    private function resultListener(event:Event):void
    {
         dgrid1.dataProvider = event.result as Array; // works perfectly
         combo1.dataProvider = event.result.data_name as Array; // displays empty combobox
    }

    <!-- MXML Code -->
    <mx:ComboBox id="combo1" /> <!-- I want to populate names here -->
    <mx:DataGrid id="dgrid1" />

    How should I do this?

    Thanks and greetings

    ShiVik

    Hello

    I faced this problem somewhere, all I remember is that the table of variables has been registered on the event.result [0].

    I don't really understand why, but it worked for me.

    Try event.result [0] .data_name

    Otherwise, you will need to run through the result manually and make your own table of data_name.

    Try to debug and see the structure of the result.

    Hope this helps,

    Salem

  • Fill ComboBox with HTTPService object

    I can't for the life of find me a good example of how call a doc by HTTPService xml, then use the data to populate a combobox control. Can someone help me with this please?

    Here's what I have so far.

    Part of the XML
    <? XML version = "1.0" encoding = "utf-8"? >
    < albumdirectory >
    < id album = details '1' = "Our trip home in 2005." >
    < title >
    Cottage 2005
    < /title >
    < safety pin = "" / > "
    < photos >
    < photo details = "" > assets/gallery/nature01_sm.jpg < / photo >
    < photo details = "" > assets/gallery/nature02_sm.jpg < / photo >
    < photo details = "" > assets/gallery/nature03_sm.jpg < / photo >
    < photo details = "" > assets/gallery/nature04_sm.jpg < / photo >
    < / photos >
    < / album >
    < / albumdirectory >

    Now, here's what I have so far for the flex code.

    < mx:HTTPService
    URL = "Assets/albums. XML ".
    ID = "albumXML".
    showBusyCursor = "true" / >

    < mx:ComboBox width = "100%" height = "8%" id = "albumBox" dataProvider = "{albumXML.lastResult.albumdirectory.album}" labelField = "title" > "

    < / mx:ComboBox >

    Any help on how I can get this fact would be great! Also good resources on "How-to" small snippets would be nice too.

    Thanks for your time

    OK sorry, it works. It was actually my xml that has been ruining things.

Maybe you are looking for

  • When I right click on a file to save it, Firefox saves it in my download folder without let me pick the destination. Can I get around this?

    When I save a file (by clicking on the right) when you use Internet Explorer, I'm allowed to choose the destination folder. However, when I use my default browser to Firefox (again, by right clicking), it simply records the file in my downloads folde

  • Satellite L500 - error at startup

    When I start up I get an error message "an error has occurred. Error #-5 "."The message invites me to "Visit http://consumer.installshield.com for more information." I have visited the site, but have not been able to find the error message that is me

  • HP 3520 will not print black

    I have a HP 3520 which do not print black.  I tried all the solutions that HP has provided, I have changed all the toner cartridges and have new HP cartridges installed, but all 3 colors of fine print, but does not at all black ink print. Bought it i

  • Photosmart 4700: stopped seeing my sd card

    I'm scanning photos. I put the sd card in the laptop to confirm that I had scanned all. I didn't so I tried to scan the bad pictures, and I can no longer get the photosmart to see the sd card. The SD card is well - she couldn't see before sd cards -

  • How can I fix code purple error on HP?

    I have currently a HP p6277c-b desktop PC running Windows 7 home prmium 64-bit. I had a Doctor in my video section of the motherboard, I first checked HP for the motherboard, but they don't sell any more.  I went online and found the same exact mothe