• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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
 
This one time, at bandcamp, I had relations with a tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic