This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes problem on html:select html:options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem on html:select html:options" Watch "problem on html:select html:options" New topic
Author

problem on html:select html:options

Agapetos Herodotos
Greenhorn

Joined: Jan 02, 2006
Posts: 8
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107
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).


- Christian
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem on html:select html:options
 
Similar Threads
html:options tag and String array
How to use html:select tag in struts
How can I used html:select with a Collection of String
html:select
list box problem