Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Dropdowns

 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to display dropdowns dynamically thru struts.
Number of dropdowns to be displayed on my JSP is decided at runtime. Sometimes 3 are displayed ans sometimes 4 depending upon the data stored in the DB for the particular user.

~Thnx
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sahil

Ofcourse u can do that . By using some logic:iterate and then having the code for the drop down inside

Hope u got what i am saying
 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya iam using the same. But, I was wondering what should i proivde in the property attribute of html:select. As the dropdown is synamically made.

can u give me some examples, please
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose if you have the collection named requestColl in the request , you can use the following code to populate the drop down.

<html:select property="selectBox" >
<html options collection="requestColl" property="id" labelProperty="name"/>
</html:select>

selectBox is the name of the drop down box. When the form is submitted, the selected id will be populated in this form variable.

hope this helps.
 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i hv done it. By using logic:iterate and html ptionsCollection combination.
thnx to all for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic