Get button label using 'getElementAt()'

Hello!
I have 100 buttons in a container and I'm trying to get label of one of them. The problem: getElementAt() returns IVisualElement and it doesn't have label property. It returns other properties right.
This line: if (cellContainer.getElementAt((row - 1)*10 + col-1).label == 'X')
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark"
                  xmlns:mx="library://ns.adobe.com/flex/mx" width="640" height="480" addedToStage="init()" backgroundColor="#CCAAAA">
     <fx:Declarations>
          <!-- Place non-visual elements (e.g., services, value objects) here -->
     </fx:Declarations>    
     <fx:Script>
          <![CDATA[
               import mx.core.IVisualElement;
               import spark.components.Button;
               private function init():void
                    for (var i:uint = 0; i < 100; i++)
                         var myCell:Button = new Button();
                         myCell.width = 32;
                         myCell.height = 32;
                         myCell.label = 'O';
                         myCell.addEventListener(MouseEvent.CLICK, clickCell);
                         cellContainer.addElement(myCell);
               public function checkForWinner():void
                    var sameMarkerInARow:uint = 0;
                    for (var row:uint = 1; row < 11; row++)
                         sameMarkerInARow = 0;
                         for (var col:uint = 1; col < 11; col++)
                              if (cellContainer.getElementAt((row - 1)*10 + col-1).label == 'X')
                                   sameMarkerInARow++;
                              }else{
                                   sameMarkerInARow = 0;
                         if (sameMarkerInARow == 5){
                              trace('WINRAR');
                              break;
               private function clickCell(event:Event):void
                    event.currentTarget.label = 'X';
                    checkForWinner();
          ]]>
     </fx:Script>
     <s:TileGroup id="cellContainer" x="10" y="10" width="320" height="320" horizontalGap="0" verticalGap="0" rowHeight="32" columnWidth="32" requestedRowCount="10" requestedColumnCount="10">
     </s:TileGroup>
</s:Application>
Thanks!

Try either of the following and tell me if it works
1. Button(cellContainer.getElementAt((row - 1)*10 + col-1)).label=='X'
2.  var button:Button=new Button()
     button=cellContainer.getElementAt((row - 1)*10 + col-1) as Button
     if (button.label == 'X')

Similar Messages

  • Why can't I get the text labels for each app to go away? I only see 9 app buttons now; used to see 30 or 40

    Text labels started showing up next to my app buttons going across toolbar. Because the names are fairly long (I don't need them per se); I can now only see about 10 buttons. I made sure the the box in the toolbar preferences menu which says "show text labels for each app." was unchecked. I even tried checking it, then unchecking it.
    I can't get the labels to go away. I used to be able to see and therefore USE EASILY about 30 -40 app buttons. I just downloaded the latest update to firefox 8.

    I am having something similar going on and can't sort out what it is doing:
    ldiffs:
    dn: automountMapName=auto_master,dc=example,dc=edu
    objectClass: top
    objectClass: automountMap
    automountMapName: auto_master
    dn: automountKey=/foo,automountMapName=auto_master,ou=Mounts,dc=soe,dc=ucsc,
    dc=edu
    objectClass: automount
    automountKey: /foo
    automountInformation: auto.foo,dc=example,dc=edu -rw,resvport,
    hard,intr,nosuid,tcp
    Second one:
    dn: automountMapName=auto.foo,dc=example,dc=edu
    objectClass: top
    objectClass: automountMap
    automountMapName: auto.foo
    dn: automountKey=tstaff,automountMapName=auto.foo,dc=example,dc=edu
    objectClass: top
    objectClass: automount
    automountInformation: fileserver:/export/foo/tstaff
    automountKey: tstaff
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 name=tstaff[] map=auto.foo,dc=example,dc=edu opts=rw,resvport,hard,intr,nosuid,tcp path=/foo direct=0
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 getmapent_ds called
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 getmapent_ds: key=[ tstaff ]
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 ds_match called
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 ds_match: key =[ tstaff ]
    9/25/09 11:45:25 AM com.apple.automountd[1101] t0xb0289000 ds_match: Searching for tstaff,automountMapName=auto.foo,dc=example,dc=edu
    9/25/09 11:45:25 AM automountd[1101] ds_search failed
    exiting ...
    It seems like it can't find the trigger point tstaff. It is looking for:
    ds_match: Searching for tstaff,automountMapName=auto.foo,dc=example,dc=edu
    which isn't what the DN is in ldap:
    Distinguished Name: automountKey=tstaff,automountMapName=auto.foo,dc=example,dc=edu
    any thoughts?
    regards,
    Derek

  • Can we get the label name of the particular oracle field using open script

    hi
    can we get the label name of the oracle fields like column name ORDER NUMBER instead of ORDER_ORDER_NUMBER_0 when recording using openscript.

    Good morning
    Do you develop functional or load test scripts?
    I don't think we can in both cases because this is really the name of the field + the index.
    The zero refers to first line normally (then 1 for second line and so on).
    "Order number" is maybe the display label which is not enough to recognize and interact with a field.
    May I ask why you want this, then it could help me (us) to give you a good solution/workaround.
    Cheers
    JB

  • What is the code to get the  Label of  radio button item at runtime?

    Hi All
    I am working on forms 10g(version 10.1.2.0.2 ) with Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 on windows 2000 platform.
    My requirement is to dynamically get the label of the radio button item in a radio group.I am able to get the label of the radio group as shown below
    Item :Radio group
    Label : Gender
    IF m_type = 'RADIO GROUP' THEN
         m_label:=Get_Item_Property(m_Item ,label);
    END IF;
    There two Radio buttons inside this radio group which are
    item     : Radio button
    Label : Male
    item :Radio button
    Label :female
    What is the code to get the label of radio button(i.e) male and female ?
    How will I get the count of radio buttons in a radio group at runtime?
    Regards
    Mohan

    But you have to provide the button name which cannot be get at runtime.
    This is a lack of information that the Dev team would correct !
    Francois

  • Trying to assign an XML attribute value to a button label

    I have a Flex app (developed in FLEX 2) that reads from
    multiple XML files and populates datagrids with element values.
    What I'm trying to do now, is to create a second column with a
    button, enabling users to view archived versions for each current
    report.
    My problem is: I can't get the <mx:Button> label to
    accept the attribute "name". I've tried atleast 10 - 20 different
    syntax.
    My XML file looks like this:
    <metrics>
    <report name="test">
    <link>test Report 10/28/2008</link>
    <url>test-10_28_2008.zip</url>
    <status>active</status>
    </report>
    </metrics>
    The mxml looks like this:
    <mx:Button buttonMode="true" useHandCursor="true"
    click="handleClick()" label="{data.@name}" width="80">
    <mx:Script>
    <![CDATA[
    public function handleClick():void{
    var url:URLRequest = new
    URLRequest([L=http://new.test.com/pages/r_archive_apps/"+data.link+".html");[/L]]http://n ew.test.com/pages/r_archive_apps/"+data.link+".html");[/L][/L]
    navigateToURL(url,"_blank");
    ]]>
    </mx:Script>
    </mx:Button>
    When I try to label a button with an element it works fine.
    Some of the other sytax I've used are:
    - label="{data.report.@name}"
    - label="{data.report.(@name=='test')}"
    - label="{data.report.(@name='test')}"
    - label="{data.@name}"
    - label="{data.metrics.report.@name}"
    - label="{data.metrics.report.(@name=='test')}"
    - label="{data.metrics.report.(@name='test')}"

    quote:
    Originally posted by:
    rtalton
    Can you post some code so we can see how you are using the
    button? I think you may be using the button within a datagrid
    itemRenderer, which might make a difference.
    You're right, the button is in a datagrid itemRenderer. I've
    pasted more dataGrid code below - thanks again.
    <mx:DataGrid id="dgCatalog" dataProvider="{_xlcCatalog}"
    rowCount="4" editable="false" sortableColumns="false"
    left="148" top="65" bottom="42" borderStyle="solid"
    alternatingItemColors="[#ecf8ff, #ffffff]"
    themeColor="#ffff80" alpha="1.0" cornerRadius="0"
    dropShadowEnabled="true" dropShadowColor="#000000" width="549"
    creationCompleteEffect="{glow3}">
    <mx:columns>
    <mx:Array>
    <mx:DataGridColumn editable="false" headerText="Daily -
    Report Names" dataField="link" textAlign="left" width="200">
    <mx:itemRenderer>
    <mx:Component>
    <mx:LinkButton click="handleClick()" label="{data.link}"
    >
    <mx:Script>
    <![CDATA[
    public function handleClick():void{
    var url:URLRequest = new URLRequest("
    http://test.new.com/test/"+data.url);
    navigateToURL(url,"_blank");
    ]]>
    </mx:Script>
    </mx:LinkButton>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    <mx:DataGridColumn editable="false" headerText="Daily -
    Report Archives" dataField="link" textAlign="left" width="80">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Button buttonMode="true" useHandCursor="true"
    click="handleClick()" label="{data.report.@name}" width="80">
    <mx:Script>
    <![CDATA[
    public function handleClick():void{
    var url:URLRequest = new URLRequest("
    http://test.new.com/pages/test_apps/"+data.link+".html");
    navigateToURL(url,"_blank");
    ]]>
    </mx:Script>
    </mx:Button>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    <!--mx:DataGridColumn headerText="URL" dataField="url"
    width="350"/>
    <mx:DataGridColumn headerText="Status" dataField="status"
    width="70"/-->
    </mx:Array>
    </mx:columns>
    </mx:DataGrid>

  • Button label positioning

    Hi,
    I am new to Flex 2 world but even my question seems a bit
    funny to me. I'm trying to create a square button (width=200 by
    height=200) and I want the label inside the button to be in one of
    the top corners. At this point I don't care if it's in the left or
    right top corner.
    I've tried everything and I was only able to get the label to
    be left aligned using the TextAlign property but I can't seem to
    figure out how to Vertically align it to the top.
    any help you be greatly appreciated.
    Incase someone needs to see the mxml code to understand what
    I'm doing, here it is: (LOL)
    <mx:Button label="topleft" width="200" height="200"
    textAlign="left"/>
    Also, I've tried to put a <mx:Label> right after this
    button and using the x/y co-ordinates, place it on TOP of the
    button and that works but then when I mouseover the label it looses
    the mouseover the button (which is obvious).
    HELP! :)

    The paddingTop worked. I just had to set it top a negative
    value :) I feel like I had to "cheat" to get this working :)
    Thanks a lot!

  • The button labels in my folders are reading as numbers

    The button labels in my folders are reading as numbers

    First, please stop posting your email address. That will only get you on spam lists.
    I suggest you erase your boot volume and restore from the backup. Check that the issue is resolved, then (and only then) change every password you have and check all your online financial accounts for unauthorized activity. Consider canceling all credit cards and requesting new ones.
    When that's done, you need to learn the basics of safe computing.
    Mac OS X versions 10.6.7 and later have built-in detection of known Mac malware in downloaded files. The recognition database is automatically updated once a day; however, you shouldn't rely on it, because the attackers are always at least a day ahead of the defenders. In most cases, there’s no benefit from any other automated protection against malware.
    The most effective defense against malware is your own intelligence. All known Mac malware takes the form of trojans that can only operate if the victim is duped into running them. If you're smarter than the malware attacker thinks you are, you won't be duped. That means, primarily, that you never install software from an untrustworthy source. How do you know a source is untrustworthy?
    Any website that prompts you to install software, such as a “codec” or “plug-in,” that comes from that same site, or an unknown site, is untrustworthy.
    A web operator who tells you that you have a “virus,” or that anything else is wrong with your computer, or that you have won a prize in a contest you never entered, is trying to commit a crime with you as the victim.
    “Cracked” versions of commercial software downloaded from a bittorrent are likely to be infected.
    Software with a corporate brand, such as Adobe Flash, must be downloaded directly from the developer’s website. No intermediary is acceptable.
    Follow these guidelines, and you’ll be as safe from malware as you can reasonably be.
    Never install any commercial "anti-virus" products for the Mac, as they all do more harm than good. If you need to be able to detect Windows malware in your files, use ClamXav -- nothing else.

  • How to localize button labels of a genuine NI VI?

    Some days ago I asked how to manage the translation of button labels of the
    genuine "file dialog VI" from NI (i.e. German label "Wahlen"-> English label
    "Select", German label "Abbruch"->English label "Cancel" etc.) for the
    finished application (I need to have a german and an English version).
    Someone suggested to select English from the Windows country selection and
    someone else suggested to use the string export/import function.
    However, nothing succeeded so far.
    I even bought WIN 2000 in English, since I thought LV perhaps refers to some
    standard/library Windows labelling names during compilation.
    Regarding the string export/import function: This should work if one is able
    to get into the VI, but with the genuine "
    file dialog VI" from NI I cannot
    enter the VI.
    Do I really have to program my own VI for such a simple localizing thing?
    So far, heavily disappointed....
    Thanks
    Klaus

    Klaus,
    Sorry to hear about your problems. Have you tried contacting NI about this? They are usually very good about supporting issues such as this.
    I am going to try a few things for you to see if I can help. If I don't post a followup, assume I had no luck. If you go to ni.com/ask you can start a formal support question. The NI tech support guys will help you fairly quickly (usually within a day or less!)
    Good luck.

  • Get Control label in SubVI

    Greetz All,
    Is it possible to get the label of a control that is connected to a subvi from within the subvi without creating a control reference and connecting it to the subvi?
    I'm trying to make some new general use subVIs, so I don't want to get a reference to the calling VI and get refs to all its controls and search for the label because what it would search for will change from application to application, so I would have a string input for the label to search for anyway.
    Thanks
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

    I realized the "wire=control" issue late yesterday. And even though I figured out how to get the control name using a variant input ternimal, then use either 'Get Variant Attribute' or convert to XML and parse out the label, there's a good chance the label will not be there anymore for one reason or another, or that there never was one because the wire didn't come from a control.
    So I've reverted back to just using a serarate string input to get the needed string into the subVI.
    Thanks
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Labeling used clips in browser (from archived thread)

    Hi all,
    This thread talks about a great tip to locate what clips have been used in a timeline by selecting the timeline clips, right-clicking and selecting Label --> Color. That should show the master clips in the browser with the same color.
    My problem is that I don't get the "Label" choice when I right-click. I can go up to Modify --> Label --> Color but it only colors the clip in the timeline...not the master clip in the browser.
    Am I missing something (I'm on FCS 1) or is there another way to find whether clips in the browser have been used in the timeline?
    Thanks in advance,
    Jonathan

    Jonathan,
    this should really work both ways.
    Select a clip in the Browser and hit cmd-opt-3 and it should label red in both the timeline and the browser.
    The reverse is true as well.
    Maybe you could try the old fashioned way of trashing preferences and repairing permissions:
    Close Final Cut Pro.
    Go to: Users/your user name/Library/Preferences.
    Drag, "com.apple.FinalCutPro.plist" to the trash.
    Scroll down to the Final Cut Pro User Settings folder.
    Drag, "Final Cut Pro 6 Preferences" to the trash.
    Drag, "Final Cut Pro Obj Cache" to the trash
    Drag, "Final Cut Pro POA Cache" to the trash.
    Go to: Applications/Utilities/Disk Utility
    Select your system disk
    Click on the Repair Permissions button
    Wait for the permissions to be repaired
    Restart your computer

  • How to change button label while loading content

    I have this basic example with toggle buttons:
    public class test extends Application
        @Override
        public void start(Stage primaryStage)
            final VBox vbox = new VBox();
            String pillButtonCss = DX57DC.class.getResource("PillButton.css").toExternalForm();
            // create 3 toggle buttons and a toogle group for them
            ToggleButton tb1 = new ToggleButton("Left Button");
            tb1.setId("pill-left");
            ToggleButton tb2 = new ToggleButton("Center Button");
            tb2.setId("pill-center");
            ToggleButton tb3 = new ToggleButton("Right Button");
            tb3.setId("pill-right");
            final ToggleGroup group = new ToggleGroup();
            tb1.setToggleGroup(group);
            tb2.setToggleGroup(group);
            tb3.setToggleGroup(group);
            // select the first button to start with
            group.selectToggle(tb1);
            final Rectangle rect1 = new Rectangle(300, 300);
            rect1.setFill(Color.DARKOLIVEGREEN);
            final Rectangle rect2 = new Rectangle(300, 300);
            rect2.setFill(Color.LAVENDER);
            final Rectangle rect3 = new Rectangle(300, 300);
            rect3.setFill(Color.LIGHTSLATEGREY);
            tb1.setUserData(rect1);
            tb2.setUserData(rect2);
            tb3.setUserData(rect3);
            group.selectedToggleProperty().addListener(new ChangeListener<Toggle>()
                @Override
                public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle)
                    if (new_toggle == null)
                    else
                        vbox.getChildren().set(1, (Node) group.getSelectedToggle().getUserData());
            HBox hBox = new HBox();
            hBox.getChildren().addAll(tb1, tb2, tb3);
            hBox.setPadding(new Insets(10, 10, 10, 10));
            hBox.getStylesheets().add(pillButtonCss);
            vbox.getChildren().addAll(hBox, (Node) group.getSelectedToggle().getUserData());
            StackPane root = new StackPane();
            root.getChildren().add(vbox);
            Scene scene = new Scene(root, 800, 850);
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args)
            launch(args);
    I noticed that if I put heavy business logic into the buttons while I switch the buttons it appears that the application hangs.
    Is it possible to display "Loading.." instead of the button label while I switch the buttons?

    Welcome to the world of multithreaded programming in JavaFX...
    It's generally a mistake to perform any long-running task in the FX Application thread, as it will cause the UI to hang while it's running. You should use the javafx.concurrent package to perform background tasks; the Task class in particular will be useful to you. The javadocs have plenty of examples.
    Note that it's also a mistake to modify the UI from a background thread, and that your Task implementation's call(...) method will be executed on a background thread. The Task class provides setOnSucceeded, setOnFailed, setOnCancelled methods to register a handler whose handle(...) method will be executed back on the FX Application thread.
    For example, the basic strategy to respond to a button press by updating the UI, launching a long-running process, and then updating the UI with the results of that process is as follows. Replace 'T' with any data type.
    myButton.setOnAction(new EventHandler<ActionEvent>() {
         @Override
         public void handle(ActionEvent event) {
              final Task<T> longRunningTask = new Task<T>() {
                   @Override
                   public T call() {
                        // perform long running operation:
                        T result = computeResult();    
                        return result ;    
              longRunningTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
                   @Override   
                   public void handle(WorkerStateEvent event) {
                        // get result of long running operation:    
                        T result = longRunningTask.getValue();
                        // now update UI on basis of result to indicate task is complete
              // update UI here to indicate task is about to run...
              // now start task:
              Thread t = new Thread(longRunningTask);
              t.setDaemon(true);
              t.start();
    There's a bunch of other functionality in Task, such as a progress property and a message property. These can be bound, and updated on the FX Application thread via the appropriate updateXXX(...) methods.

  • How do I use Address Book to print multiple labels using just one address?

    Hi. I'm trying to print multiple address labels using the same address on each label, but I'm stuck trying to make this happen in Address Book. Can anyone help?
    Thanks!

    The work-around that I've found to solve this issue is to create a new group in address book, then duplicate the contact 20 times or so, and drag the duplicates to the group you've created. Then, when you go to print, you will have a sheet of 20 or so duplicate labels. If you want to save it to repeat this task later, you can select "save as PDF" in the print menu, and simply print the PDF file next time. (assuming you use the same size labels next time, of course) Then, don't forget to delete the umteen duplicates from address book, taking care not to delete the original.
    Not the perfect solution, but it gets the job done. Maybe somebody wants to make an automator action that will do this?

  • HT1947 If you add music VIDEOS to Up Next playlist, then go to look at the album cover playing screen, then go to add another song from diff playlist, no longer can see Up Next, just go to full screen mode button. Using remote app iphone 5 to play out of

    If you add music videos to Up Next playlist, then go to look at the album cover playing screen, then go to add another song from different playlist, you no longer can see Up Next, just go to full screen mode button. Using remote app iPhone 5 to play out of iTunes. It looks like it works fine for regular music, but for music videos you can't see your up next unless you go back on the computer to change once you've left the screen. When using the remote app, you shouldn't need to go to iTunes on the PC to view or edit Up Next already added. See first image, you can hit upper right and get back to Up Next (second image). Third image is music video, where you can't get back to Up Next, just swap between full screen and not. I hoped 3.0.1 would have the answer, no luck!

    wow, very nice review Makes me want to get a vision for myself.
    WebKnight wrote:
    <SPAN>
    Add the ability to randomly select a new background from a pre selected group of photos every time the player is turned on or each day.
    I would love that feature. I can't stand useing my computer with a single wall paper anymore (I have 500 anime pics that i rotate between every 2 mins ) If you could make the vision rotate background every x minutes or every time the player is turned on, it would be totally amazeningly sweet!!!! (i might have to go out and buy one then :P)
    I just hope that creative has better firmware support with the vision than they have had with the touch.
    Once again, great review

  • How do I enable the button to use the tree list in excel? (Enable the list type: Tree enabled in Office 2013 - VSTF 2013)

    Hi, I was looking to see if anyone knows how I can troubleshoot my connection problem with TFS view in excel. I'm trying to  produce a tree view in Office 2013 as described in the following KB -
    https://msdn.microsoft.com/en-us/library/dd286627.aspx
    I have followed the instructions on the KB all the way up to : 'Add backlog items and tasks and their parent-child links using a tree list' and at this point I can't seem to get it to work as the button is greyed out.
    Note that I have completed steps 1-6 for the previous procedure... all 6 steps work just fine. However on step 2 of the second procedure - the instructions state I should be able to 'Add Tree Level' - However the button is greyed out.
    Anyone know what I need to do to enable the button to use the tree list in excel? 
    Frank

    Frank,
    I believe your issue is that you have opened a Flat query and are trying to add tree levels. A flat query is just that and you cannot change the query type from Excel.
    The second process is managing a backlog (which is a tree). TFS web access has a link on the backlog view to create a query. That query will be a "tree of work items" query that returns the items in the backlog including their parent-child relationships.
    This type of query supports the Add Tree Level and Add Child functionality as does a new Input List (not bound to an existing query).
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • How to get the label on selectOneMenu selected item??

    Hi,
    I'm not able to get the label of the selected item in a selectOneMenu. The code I use to fill it is:
    <h:form id="formNacion" name="formNacion">
    <h:selectOneMenu value="#{modelRtbBean.nacion}" id="selectNacion" onchange="this.form.submit();">
    <f:selectItems value="#{dataRecoveryBean.naciones}" id="idItemsNacion"/>
    </h:selectOneMenu>
    </h:form>
    The dataRecoveryBean has this method to fill the content of the component (basically it creates an arrayList of selectItems by recovering data from a database):
    public ArrayList<SelectItem> getNaciones() {
    if ((naciones == null ) || (naciones.isEmpty()) ){
    naciones = new ArrayList<SelectItem>();
    HDBGeografico hdbGeo = new HDBGeografico();
    SqlMadd sqlmadd = new SqlMadd();
    try {
    AccessBD sscm = new AccessBD( );
    sscm.table(hdbGeo.getSqlNaci());
    // The AccessBD object has a reference to the resultset:
    ResultSet rs = sscm.getRS();
    while (rs.next()) {
    naciones.add(new SelectItem((String) rs.getString(1), (String) rs.getString(2)));
    sscm.Close();
    } catch (Exception e) {
    System.out.println(e.toString());
    return naciones;
    the modelRtbBean setNacion recovers the value, but I need its label too, because it's a kind of description that I use later.
    In the modelRtbBean setNacion method I'm able to access the UISelectItems object, but I cannot get the selected item itself
    public void setNacion(String nacion) {
    FacesContext fc = FacesContext.getCurrentInstance();
    if (fc != null) {
    UIViewRoot viewRoot= fc.getViewRoot();
    System.out.println(viewRoot.getViewId());
    HtmlSelectOneMenu selNac = (HtmlSelectOneMenu)viewRoot.findComponent("bodySTB:formNacion:selectNacion");
    if (selNac != null) {
    System.out.println("Nacion value-htmlSelectOneMenu :" + selNac.getValue() );
    System.out.println(selNac.getAccesskey() + selNac.getTitle() + selNac.toString());
    UISelectItems uis = (UISelectItems)selNac.findComponent("idItemsNacion");
    if (uis != null) {
    System.out.println("I have the element...");
    this.nacion = nacion;
    How could it be accessed this selected item label ??

    I finally did it as you suggest, but I found another way to access the label (I don't know if it could be useful for anybody but here it is) :
    In the setter method linked to the SelectOneMenu, you can put in this code:
    FacesContext fc = FacesContext.getCurrentInstance();
    if (fc != null) {
    UIViewRoot viewRoot= fc.getViewRoot();
    System.out.println(viewRoot.getViewId());
    HtmlSelectOneMenu sel = (HtmlSelectOneMenu)viewRoot.findComponent("viewName:formName:selectOneName");
    if (sel != null) {
    UISelectItems uis = (UISelectItems)sel.findComponent("idItemsName");
    if (uis != null) {
    ArrayList<SelectItem> listElem = (ArrayList<SelectItem>) uis.getValue();
    You could put in in the value item of each SelectItem it's index position in the list, so in the setter method
    of the bean linked to the selectOneMenu you would get the index of the selected item as the parameter of the method
    int index = 1; // For easyness in this example
    System.out.println("Label: " + listElem.get(index).getLabel() + " Value: "+ listElem.get(index).getValue());
    Thanks !!!

Maybe you are looking for