Set default value of select using java in Struts 1.x

Organiccat picture Organiccat · Aug 3, 2011 · Viewed 13.1k times · Source

I've come across answers for Struts 2.x but none for struts 1.x.

All I need to do is select a default value on page load using 1.x of an HTML:SELECT tag that uses an optioncollector:

<html:select property="status">
  <html:optionsCollection name="statusList" label="description" value="id" />
</html:select>

Seems simple, but I'd like to avoid using javascript for this.

Answer

user159088 picture user159088 · Aug 3, 2011

Have you tried to use the value attribute on the <html:select> tag?

<html:select property="status" value="...your status choise here...">
  <html:optionsCollection name="statusList" label="description" value="id" />
</html:select>