tags:

views:

66

answers:

2

hi my dropdown has some 3 values

1)Apple 2)mango 3)grape

when my page loads my dropdown is defaulted to Apple(first value)

how can i make dropdown defaulted to empty and when i clicked on dropdown it should show the values

in java jsf (i am getting dropdown values as List)

+1  A: 

I would just add an empty option, and validate as needs be.

Neil McKeown
+1  A: 

I generally add an empty field with a null ID and a value that says something like "Select Fruit". I believe you can have both selectItem and selectItems. So something like this should work inside your JSF selectOneMenu component:

<f:selectItem itemValue="" itemLabel="Select Fruit" />
<f:selectItems value="#{fruitList}" />
hoffmandirt