Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

selected value through select items  RSS feed

 
nsathishbabu nagarajan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All
I am using h:selectOneMenu and f:selectItem to display a drop down element.In the f:selectItem i am need a element to be preselected how we have do this
<h:selectOneMenu id="xyz" value="#{bean.value}">
<f:selectItems value="#{bean.errMapList}"/> </h:selectOneMenu>

In the list i am adding a selectItem
errMapList.add(new SelectItem(element.getId()+"",element.getName()));

Now i want a value to be selected in the drop down box like selected in html

Regards
Sathish
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


you have bound the value of your selectOneMenu to the "value" attribute of your bean, so set the value in the "value" attribute of your bean that you want to display selected means that when your h:selectOneMenu will render before it your bean's "value" attribute should hold the value that you want to display selected.

It will automtically select that value.
 
nsathishbabu nagarajan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes its getting displayed in the order of which i add in the selectItem() but my problem is at the time of loading i want particular value to be selected at the drop down.

for ex: In html option we have property called selected so when the page loaded the particular value will be as default value in the drop down.

Regards
Sathish
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assign that selected property to the bean's "value" attribute
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!