• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

selected value through select items

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
assign that selected property to the bean's "value" attribute
 
All of the following truths are shameless lies. But what about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic