File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts html list drop down question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts html list drop down question" Watch "struts html list drop down question" New topic

struts html list drop down question

Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
I have a question based on same thing.
I have a list drop down for 3 elements.

I have html code as:
<!--<SELECT name=select2>
<OPTION selected>Start With</OPTION>

<INPUT value=123 name=textfield22242232>

and a text field next to it. How do i write this in struts html tags? How to write these in the class.
I have defined getter setter methods separately for this text field but i don't know how to define one for this list drop down. Please let me know.thanks.
Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
<html:select name="whatever">
<html ptions collection="sList" property="planDrop" labelProperty="planDrop" />

i found above in struts manual.
However, I am not sure how to put the getter setter method in MyForm.
Could anyone help?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32793

Use the property attribute instead of the name attribute in your struts select tag. Name specifies the name of the bean to look in for values. Property specifies the form field (and therefore getters/setters) to map to.

If your three items are always the same, it may be overkill to put them in a List. Instead try:

or if you have different names and values:

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: struts html list drop down question
It's not a secret anymore!