0 Replies Latest reply on Jan 29, 2010 12:28 PM by reyaron

    h:selectOneMenu - empty string value becomes null

    reyaron
      Why does the default empty string value of myBackingBean.yearStr becomes null after the page is loaded?
      My Environment:
      I am using RichFaces 3.3 with JBOSS 6, and Seam 2.1.2
      Its working well without seam

      <h:selectOneMenu id="year" value="#{myBackingBean.yearStr}">
              <a4j:support focus="year" event="onchange" reRender="myDataTable" ignoreDupResponses="true" />
              <f:selectItems value="#{comboBoxUtil.yearsValues}" />
      </h:selectOneMenu>

      comboBoxUtil code:
      public List<SelectItem> getYearsValues() { 
              List<SelectItem> items = new LinkedList<SelectItem>();               
                             
              items.add(new SelectItem("", ""); //Most important line:

              for (int i = 1; i < 10; i++) {
                      items.add(new SelectItem("0" + i, EMPTY + i));
              }


              for (int i = 10; i < 100; i++) {
                      items.add(new SelectItem(EMPTY + i, EMPTY + i));
              }
              return items;
      }

      The declaration of yearStr in the backing bean (there is also getter and setter):
      private String yearStr = "";