The html tags don't support what you want directly; if you specify a 'value' attribute it always takes precedence. You can set the default in the form bean (either in your setup action, or using <jsp:setProperty/> or similar in the JSP page) and not use a value attribute or, if that's not possible, you can use an expression for the value attribute to get the behaviour you want.

For example, assuming there is a bean named 'selectedCountry' with the value 'US', you could use something like the following:
    <html:select property="countryID" tabindex="11"
        value="${empty MyFormBean.countryID
                       ? selectedCountry
                       : MyFormBean.countryID}">

HTH,

L.

Ansley, Tom wrote:

Hi Ichy,

I did think about that but the way my global settings are set the
default value for country is found in the jsp page.  Maybe I need to
rethink this.  I was just hoping there might be another workaround.
i.e. somehow first check the bean and if nothing then use the default
value.

Yes, getCountryID() is a method of the ActionForm.

Thanks
Tom

-----Original Message-----
From: ichy [mailto:[EMAIL PROTECTED] Sent: Thursday, July 14, 2005 10:06 AM
To: Struts Users Mailing List
Subject: Re: html:select default value overwriting bean value

Hi, Tom

did you try to use ActionForm#reset() to set default
value for countryID to US ?
 getCountryID() you are talking is a method of
ActionForm, right?
 ichy


--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/


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

Reply via email to