This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Code optimization for html:option tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Code optimization for html:option tag" Watch "Code optimization for html:option tag" New topic
Author

Code optimization for html:option tag

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,
I would like to optimize the following code :

<html:select property="selectedItem">
<html ption value="1">show topics for last 1 day</html ption>
<html ption value="2">show topics for last 2 day</html ption>
<html ption value="3">show topics for last 3 day</html ption>
<html ption value="4">show topics for last 4 day</html ption>
<html ption value="5">show topics for last 5 day</html ption>
<html ption value="6">show topics for last 6 day</html ption>
:
:
:
<html ption value="31">show topics for last 31 days</html ption>
</html:select>

If you have any suggestions, please let me know
regards
sudha
Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
You may try the following, if you have the option of using <html-el:xxxx> tags -


[ August 30, 2007: Message edited by: Bhaskar Reddy ]
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
You can create an array of LabelValueBeans and use htmlptionsCollection:

Action Class:

JSP:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Code optimization for html:option tag
 
Similar Threads
Enabling / disabling forms (Struts)
update html:options
assign two properties to a submit button
how to get the default values when the jsp page is submited
html:select in Struts