Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set Default selection in h:selectOneMenu

 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers, how can one set up a default value in a drop-down menu. For instance, if the drop down has "one", "two", "three" and "four" in the drop list. How can one programmatically set "three" as the default when the page is loaded.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By using the value attribute of the selectOneMenu tag.
 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't mean how to obtain the selected value on the selectOneMenu, but to set pre-selected value on the drop-down when the page is loaded. To achive this in HTML, here is an example on how to set three as pre-selected value.
<pre>
<select name="numbers">
<option value="one">one</option>
<option value="two">two</option>
<option value="three" selected="selected">three</option>
<option value="four">four</option>
</select>
</pre>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what the value attribute is for, isn't it ?
 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris, I've solved the issue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic