2 Replies Latest reply on May 10, 2007 10:30 AM by matt.drees

    problem with s:selectItems and noSelectionLabel

    matt.drees

      I have a simple array of strings backing an <s:selectItems> for an <h:selectOneMenu>. When I don't set noSelectionLabel, it works fine. It renders the options something like

      <option value="durango">durango</option>
      

      However, when I set noSelectionLabel, the menu doesn't function, because the options are rendered like
      <option>durango</option>


      After some debugging, I found that the problem is in the ConverterChain that is attached to the HtmlSelectOneMenu component. JSF calls the converter to convert the value "durango" to a string during rendering, but the converter returns null (there's only one converter attached to the chain, a NoSelectionConverter, which returns NO_SELECTION_VALUE, so the chain returns null).

      It looks like the there is normally a default converter to fall back on. I think the ConverterChain constructor tries to create a default converter based on the type of the value, but this doesn't work for Strings (debugging showed that facesContext.getApplication().createConverter(String.class) returns null).

      So, I think the solution would be to have the ConverterChain constructor create a default pass-through String converter when valueBinding.getType(facesContext) is equal to String.class.