This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

selected value through select items  RSS feed

 
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
 
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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!