MyFaces Core
  1. MyFaces Core
  2. MYFACES-1759

JSR-252 Issue #69: Permit the passing of a null value to SelectItem.setValue(). A SelectItem with null value adds message Value is not valid

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.2
    • Component/s: JSR-252
    • Labels:
      None
    • Environment:
      tomcat 6, myfaces-1.2.1-SNAPSHOT (05 nov 2007)

      Description

      The following code:

      <h:selectOneListbox id="si" binding="#

      {selectItemBean.component}

      "
      value="#

      {selectItemBean.value}

      ">
      <f:selectItems value="#

      {selectItemBean.list}

      "/>
      </h:selectOneListbox>

      If the list is created as is:

      public List<SelectItem> getList()

      { List<SelectItem> lista = new ArrayList<SelectItem>(); lista.add(new SelectItem(null, "NULL 2"); lista.add(new SelectItem("", "EMPTY")); lista.add(new SelectItem("1", "Value 1")); lista.add(new SelectItem("2", "Value 2")); return lista; }

      Render this:

      <select id="form:si" name="form:si" size="4">
      <option value="" selected="selected">NULL 2</option>
      <option value="" selected="selected">EMPTY</option>
      <option value="1">Value 1</option>
      <option value="2">Value 2</option>
      </select>

      null and empty String values are annotated equally.

      The problem is that JSF RI assumes value="" as null when converting the value, but myfaces assumes empty String.

      The submited value is an empty String, decoded on JSF RI as null and on Myfaces as empty String.
      JSF RI does not show this item as selected but set the value
      correctly to null. Myfaces sends a validation message "Validation Error: Value is not valid".

      To be according to the spec, the preferred behavior is that JSF RI shows, so it's necessary a correction on myfaces to be compatible.

        Activity

        Leonardo Uribe made changes -
        Fix Version/s 1.2.2 [ 12312932 ]
        Fix Version/s 1.2.1 [ 12312895 ]
        Leonardo Uribe made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Leonardo Uribe made changes -
        Fix Version/s 1.2.1 [ 12312895 ]
        Fix Version/s 1.2.1-SNAPSHOT [ 12312571 ]
        Matthias Weßendorf made changes -
        Fix Version/s 1.2.1-SNAPSHOT [ 12312571 ]
        Resolution Fixed [ 1 ]
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Leonardo Uribe made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Leonardo Uribe made changes -
        Field Original Value New Value
        Attachment patchNullUISelectOne.patch [ 12369315 ]
        Leonardo Uribe created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Leonardo Uribe
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development