File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes help on html:select for default value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "help on html:select for default value" Watch "help on html:select for default value" New topic

help on html:select for default value

jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
I have a dropdown list getting from a collection in database,
I need to set one of the value in this dropdown as default, how do i do it via STruts tag;
Many thanks for your help.

ps: in hard code select, just added "selected" to one to the option, but not sure how to approach this
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Sometime prior to this portion of the JSP code (preferably in your Action class), simply set the value of the regionCode property in your form bean to the value theat you want as the default:


Struts automatically selects the option that matches the value of the property specified in the <html:select> tag.

Consultant, Sima Solutions
It is sorta covered in the JavaRanch Style Guide.
subject: help on html:select for default value