Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sturts Urgent query

 
Mukesh Kumar Yadav
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using sturts and Hibernate and struts.
I am new to struts and Hibernate framework.I am trying to populate the combobox.but don't get any success yet.
I have a leftpannel filled with various links.I want, once I click one of these links,say productEntry link, a jsp pages get loaded which carries a combobox.This combobox get populated automatically from database.

could anyone help me out by giving me a sample code.
 
Vinod K Singh
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how to fetch data from database using Hibernate? If yes, then fetch the desired data and populate the combobox by iterating over it. logic:iterate tag of JSTL foreach tags will be helpful here.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

In your Action class first make one list which retrieve your combo box value like

private List<Country> countryList = getCountryList();

then jsp you can populate this country list using s:select like.

<s:select theme="simple" name="country.countryName"
list="countryList" listKey="countryName"
listValue="countryId"
value="%{country.countryId}" />


Thanks,
Nishan Patel.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic