0 Replies Latest reply on Sep 29, 2010 6:00 AM by jethroborsje

    rich:comboBox & enum

    jethroborsje

      Hi all,

       

      I am trying to use an enumeration together with a rich:comboBox. For some reason the rich:comboBox shows the toString() of the passed enum value instead of the label as defined in the SelectItem. When I use a h:selectOneMenu everything works fine, but I like the additional options of the rich:comboBox. I will post relevant code bellow:

       

      .xhtml code:

       

      <rich:comboBox id="test" directInputSuggestions="true" defaultLabel="Make a choice" 
           value="#{controller.entity.soort}">
           <f:selectItems value="#{enumerationBean.soorten}" />
      </rich:comboBox>
      

       

      enumerationBean:

       

      public List<SelectItem> getSoorten() {
          List<SelectItem> items = new ArrayList<SelectItem>();
          for (Soort soort : Soort.values()) {
              items.add(new SelectItem(soort, soort.getLabel()));
          }
          return items;
      }
      

       

      enum:

       

      public enum Soort {
          SOORT_1("soort 1"), SOORT_2("soort 2"), SOORT_3("soort 3"), SOORT_A("A soort"), SOORT_B("b soort"), SOORT_C(
                  "c soort");
      
          private String label;
      
          private Soort(String label) {
              this.label = label;
          }
      
          public String getLabel() {
              return label;
          }
      }
      

       

      Is this a bug in RichFaces or am I doing something wrong?

       

      Best regards,

      Jethro