Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help on html:select for default value

 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

myForm.setRegionCode("xx");

Struts automatically selects the option that matches the value of the property specified in the <html:select> tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic