0

There is a similar question on this site asking for how to set the default vaule for an HTML object.

This relies on setting a "value" tag for an individually-listed <option>, but I am using an optionsCollection, with a pre-set list of options.

<html:select property="optionsList">
    <html:optionsCollection name="lutOptions"/>
</html:select>

I tried indicating the desired option to be selected, but it doesn't appear to work. Instead, it just creates a new option for the list at the bottom.

<option selected="selected">desired option</option>

How do I set one of the options from the lutOptions list to be the default option for my optionsCollection object?

Community
  • 1
  • 1
Zibbobz
  • 725
  • 1
  • 15
  • 41

1 Answers1

1

Maybe this link can help you.

http://www.coderanch.com/t/54537/Struts/Set-default-html-select

As mentioned in the link, you can set the ActionForm bean property to the appropriate value. There are three ways to set the ActionForm bean property:

  1. You can set it in an Action class that forwards to the JSP
  2. You can set it in the JSP itself with a <c:set> tag
  3. You can set this value in the reset() method of the ActionForm bean
Aditya Gupta
  • 633
  • 1
  • 4
  • 11
  • Somewhat helpful, but it could use more explanation - It offers three possible solutions, but no implementation for any of those solutions. I will try just setting the value though, and see if it sticks. As a note, while this link is useful, links can go dead or otherwise be inaccessible, so you may want to update this answer with an explanation of the answer provided by the link. – Zibbobz Jun 28 '16 at 13:11
  • Edited it. Thanks for the advice. – Aditya Gupta Jun 29 '16 at 05:37