You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Schaare <Lo...@gmx.de> on 2004/03/10 10:30:38 UTC
How to set the selected value in an select rendered by optionsCollection
I´ve got this select rendered with data from my applicationwide
formularBean:
<html:select property="testSelect" size="1" titleKey="label.Anrede.title">
<html:optionsCollection name="fb" property="hmAnreden" label="value"
value="key"/>
</html:select>
This renders a select like this:
<select ...>
<option>Mrs.</option>
<option>Mr.</option>
<option>Dr.</option>
.
.
</select>
The formular fields in my JSP should be prefilled with data from my person
bean ("sb")
which has a Title property, so sb.getTitle() returns 'Mr.' in this example.
Is there any chance to tell the html:select renderer "hey, if sb.getTitle()
is = 'Mr.' write
<select ...>
<option>Mrs.</option>
<option selectet>Mr.</option>
<option>Dr.</option>
.
.
</select>" ???
I tried this workaround:
<html:select property="testSelect" size="1" titleKey="label.Anrede.title">
<html:option key="<%=sb.getTitle()%>" value="<%=sb.getTitle()%>" />
<html:optionsCollection name="fb" property="hmAnreden" label="value"
value="key"/>
</html:select>
but it rendered:
<select ...>
<option>Mr.</option>
<option>Mrs.</option>
<option>Mr.</option>
<option>Dr.</option>
</select>
even if Validator returns to this page because of errors.
Do you have any solutions/suggestions/articels for me to solve this problem
?
--
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org