Search code examples
javajsfdrop-down-menurichfacesdefault-value

Set a default value to a rich:select component which has enableManualInput set to true?


<rich:select id="miDisabled" enableManualInput="false" value="bar">
    <f:selectItem itemLabel="foo" itemValue="foo" />
    <f:selectItem itemLabel="bar" itemValue="bar" />
</rich:select>

<rich:select id="miEnabled" enableManualInput="true" value="bar">
    <f:selectItem itemLabel="foo" itemValue="foo" />
    <f:selectItem itemLabel="bar" itemValue="bar" />
</rich:select>

Both rich:selects have "bar" value selected by default, but miDisabled's dropdownlist has two available values "foo" and "bar" as expected, while miEnabled's only have "bar": "foo" disappeared...

Any other way to set a default value to a rich:select component which has enableManualInput set to true?


  • RichFaces 4.1.0
  • JSF 2.1.21
  • JDK 6u20 x32

Solution

  • But the default value is being set, isn't it?

    With manual input enabled the dropdownlist is filtered by what you type in. If you want to show all items all the time you have to set clientFilterFunction for rich:select.

    filter = function(discardTypedValue, item) {
        return item;
    }