The html:select tag should do this automatically for you I think. Try not
explicitly setting the value attribute.

Looking at your code I'm surprised it works - you can;t nest jsp tags inside
other tags as far as I know (or is that a JSP 2 feature?).

Paul

> -----Original Message-----
> From: Matthew Hegarty [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 23, 2004 2:14 PM
> To: 'Struts Users Mailing List'
> Subject: html:select - can't display default option
> 
> 
> 
> Hi all
> 
> I am using <html:select>, and trying to get the drop-down to 
> default to a Boolean value in a bean, ie true, false, or 
> blank if the bean is null.
> My bean (MyBean) contains the method getMyValue() which 
> returns a Boolean object.
> 
> In the code snippet below, the c:out statement confirms that 
> the value of the property is 'true'.  I expect that the 
> 'true' option will be pre-selected (which it is if you add 
> "value='true'" to html:select), but doing this dynamically 
> with the c:out tag doesn't work - the blank value is always the
> one pre-selected.
> 
> Can someone suggest anything I am doing wrong, or suggest a 
> better approach (i'm relatively new to Struts).
> 
>             <c:out value='${MyBean.myValue}' /><br>
>             <html:select name="MyBean" property="myValue" 
> value="<c:out value='${MyBean.myValue}' />">
>                 <html:option value="" 
> key="jsp.form.booleandropdown.default" bundle="JSP_LABELS" />
>                 <html:option value="true" 
> key="jsp.form.booleandropdown.true" bundle="JSP_LABELS" />
>                 <html:option value="false" 
> key="jsp.form.booleandropdown.false" bundle="JSP_LABELS" />
>             </html:select>
> 
> Thanks
> Matt
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


**********************************************************************
Axios Email Confidentiality Footer
Privileged/Confidential Information may be contained in this message. If you are not 
the addressee indicated in this message (or responsible for delivery of the message to 
such person), you may not copy or deliver this message to anyone. In such case, you 
should destroy this message, and notify us immediately. If you or your employer does 
not consent to Internet email messages of this kind, please advise us immediately. 
Opinions, conclusions and other information expressed in this message are not given or 
endorsed by my Company or employer unless otherwise indicated by an authorised 
representative independent of this message.
WARNING:
While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted 
via electronic mail attachments we cannot guarantee that attachments do not contain 
computer virus code.  You are therefore strongly advised to undertake anti virus 
checks prior to accessing the attachment to this electronic mail.  Axios Systems Ltd 
grants no warranties regarding performance use or quality of any attachment and 
undertakes no liability for loss or damage howsoever caused.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to