| Author |
h:selectOneMenu values customization
|
Anantha Ramachandra
Greenhorn
Joined: Feb 06, 2008
Posts: 4
|
|
I have a select one menu with a selectedItem ( labelled as "ALL") and a list of selectedItems from the managed bean. How do I hide the select option "ALL" when there is only one selected item in the selectedItems list, by making changes to the web page ( through JSF expression or Javascript) only.
example:
<h:selectOneMenu id="stationId" value="#{manageBagIrregularitiesBean.flightQueryInfo.station}" tabindex="1">
<f:selectItem value="ALL"/>
<f:selectItems value="#{flightInfoBean.userStations}" />
</h:selectOneMenu>
"ALL" needs to be hidden if flightInfoBean.userStations list has only one value, changes to the backing bean's java code is not allowed.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14561
|
|
In theory, you could set the "itemDisabled" attribute based on the EL-computed length of the selectItem list. In practice, apparently itemDisabled isn't very reliable, and the actual documented behavior doesn't guarantee hiding that item (it could grey it out, for example). "f" elements, unfortunately, are modfiers, so there's no "rendered" attribute"
Probably the most reliable, if not pleasant, way to do this is make 2 copies of the control, one with the "ALL" selectItem, one without and set up their respectived rendered= attributes to display the desired one based on the length of the selectItem list.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: h:selectOneMenu values customization
|
|
|