struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hegarty <>
Subject html:select - can't display default option
Date Fri, 23 Apr 2004 13:13:50 GMT

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"


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message