You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Ansley, Tom" <To...@csgsystems.com> on 2005/07/14 17:46:08 UTC

html:select default value overwriting bean value

Hi all,

 

I have the following code:

 

  <td class="form_field" width='34%'>

      <html:select property="countryID" tabindex="11">

            <html:options collection="country" property="ID"
labelProperty="country"/>

      </html:select>

  </td>

 

Which basically gets a list of countries and displays them.  But, it
also gets the value that resides in the beans getCountryID method and
sets the value of the drop down to that.

 

But, if I do this:

 

  <td class="form_field" width='34%'>

      <html:select property="countryID" tabindex="11" value="US">

            <html:options collection="country" property="ID"
labelProperty="country"/>

      </html:select>

  </td>

 

The value="US" always overwrites what is in the bean.

 

I would like it to only put that default value into the page if there is
NO value in the bean.

 

Can this be done? 

 

Thanks

Tom Ansley


Re: html:select default value overwriting bean value

Posted by ichy <ic...@gmail.com>.
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