javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-1187

SelectItem ignores null value if used with converter that returns null

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Glassfish 3.1.2

      Description

      Using a 'selectItem' with a 'null' value and a converter that will return 'null' for this value will ignore the value in the html output.

      If the value is ignored not renderd in html 'select' tag the submitted value will be the label since no value was provided.

      site.xhtml
      <f:selectItem itemLabel="None" itemValue="#{null}"/>
      
      TestConverter.java
      
      @Override
      public String getAsString(final FacesContext context, final UIComponent component, final Object value)
      {
      	if (value == null)
      		return null;
      	else
      		return String.valueOf(value);
      }
      
      @Override
      public Object getAsObject(final FacesContext context, final UIComponent component, final String value)
      {
      	if (value == null || value.trim() == "")
      		return null;
      
      	// convert string to object here just example
      
      	return null;
      }
      
      Html output
      <option>None</option>
      

      Submitting the form will lead to a conversion error: "None" cannot be converted...
      since html takes the label as the value if no value is provided.

      Should the desired html not be in which case the conversion would succeed.

      Html output desired
      <option value="">None</option>
      

      Returning empty String would lead to desired behavior. But I would prefer returning null instead, and also because of issue: https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1180

        Activity

        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.
        Hide
        Manfred Riem added a comment -

        Setting priority to Minor

        Show
        Manfred Riem added a comment - Setting priority to Minor

          People

          • Assignee:
            Unassigned
            Reporter:
            djmj
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: