Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem on html:select html:options

 
Agapetos Herodotos
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have a problem on html:select html ptions /html:select

in simple tml tags we have the selected field to enable default selection of a data inside the options tag...

but how can i do this in struts???

example
html:select property="birthPlace" styleClass="fieldGray"
html ptions collection="Countries" property="value" labelProperty="label"
/html:select
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since <html:xxx> tags are tied to a property of the ActionForm, you can set a default for any <html:xxx> tag by setting the corresponding property in your ActionForm bean. For example, if you put the following statement in your Action class:

myActionForm.setBirthPlace("Japan");

The default value in your <html:select property="birthPlace" > tag will be "Japan", provided "Japan" is one of the available options.
 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Agapetos,

you said
<b>
example
html:select property="birthPlace" styleClass="fieldGray"
html ptions collection="Countries" property="value" labelProperty="label"
/html:select
</b>

You can add the default country(any country which you want as default) at the beginning or apex of your collection( Countries )if that is what you want(I assume you have a dropdown of countries).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic