aspose file tools
The moose likes JSF and the fly likes h:selectOneMenu values customization Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "h:selectOneMenu values customization" Watch "h:selectOneMenu values customization" New topic
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
    
    7

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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: h:selectOneMenu values customization
 
Similar Threads
Select value
Getting One Dropdown Menu Selection to Affect the Values of a Second Dropdown Menu
Session scoped bean's listener invoked before request scoped bean's set method
How to get selectOneMenu value
toggle checkbox group when the max limit is reached