I'm not sure if I fully understand, but why not use:
if (sb.getTitle().equals("Mr."))
formularBean.setTestSelect(sb.getTitle())
in your preprocessing action class to set the value of "testSelect", which will
automatically add the SELECTED attribute on the option tag?
Regards,
Shahak Nagiel
-----Original Message-----
From: Frank Schaare [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 10, 2004 4:31 AM
To: [EMAIL PROTECTED]
Subject: 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]