1 Reply Latest reply on Apr 2, 2012 8:59 AM by giant2

    Crazy Combobox

    giant2 Newbie

      Hi all!

      I'm now in war with rich:combobox and f:selectItems

      Why?? It's simple! Label is ignored!!!


      I try to explain me better.

      My xhtml page has:

      <rich:comboBox defaultLabel="Make a choice" value="#{myBean.chs.get(0).label}">

                          <f:selectItems value="#{myBean.chs}" var="ch" itemLabel="#{ch.label}" itemValue="#{ch}" />



      My java code is:

      public List<MySelectItem> getChs(){

           List<SelectItem> ret = new ArrayList<SelectItem>();

           for (int i=0;i<10;i++){

                SelectItem si=new SelectItem();

                si.setValue("The value "+i);

                si.setLabel("The label "+i);


           return ret;




      The strange is that my choice has a visualization like following containing 10 elements... but for each element display "The value xxx"

      Ad label? Why we can specify if they aren't used?

      I try to create an extended class of SelectItem and put a System.out.println each every call to getValue and getLabel methods.

      I see the getValue methods are called, but getLabel methods aren't!!!!!!!


      If I need to specify a visual appearance String, but a different thing must be manipulated by the server, it's impossible!!!!!

      I'm becaming crazy. How can I link a select item to an object?

        • 1. Re: Crazy Combobox
          giant2 Newbie

          solved myself using a Converter.


          Extending this you must create a getAsObject and a getAsString methods used for mapping the value viewed with the value object.

          In this manner you can do a simply multi-language system.