File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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
 
 
subject: problem on html:select html:options