The Primefaces p:selectOneMenu component does not seem to bring focus to a previously selected item. For example, if I have a menu of countries set up as follows
<p:selectOneMenu id="countryMenu" value="#{myBean.selectedCountry}">
<f:selectItem value="#{null}" itemLabel="Please select a Country..."/>
<f:selectItems value="#{myBean.countries}" var="country"
itemValue="#{country.code}"
itemLabel="#{country.name}"/>
<p:ajax update="anotherComponent"/>
</p:selectOneMenu>
and I select a country from the list, then click on the menu again it displays the list of countries from the beginning. It does retain the selected country – it just doesn’t scroll down and focus on it.
The standard JSF h:selectOneMenu displays the expected behaviour – it opens with the previously selected country visible.
Is there some trick to this or is this a bug?
It also has a number of other quirks with how it responds to keyboard input (pressing up/down when the menu has focus doesn’t open the menu, for example), which is a little frustrating.
I’m using:
- Primefaces 3.1
- Glassfish 3.1.1
- NetBeans 7.1
Ok, this appears to have been fixed!
I ran some tests with various versions of Primefaces with the following results:
3.1 – didn’t work
3.2 – didn’t work
3.3 – didn’t work (previously selected value flickers briefly, then the first menu item is displayed)
3.4 – works as expected
Note: I did need to clear my browser cache (in Chrome and Firefox) when upgrading from 3.3 to 3.4 (the items weren’t selectable at all until I did this).