I use the html:options tag :
Just create a Collection (here gender of the Databaseentries (f,m) and
pass as a bean to the page
with the form.
html:select name=yourForm property=gender
html:options collection=gender property=id
labelProperty=description/
/html:select
If you need more
Hello,
I always use the html:options tag and it works fine; try the following:
(there is a type error in your example)
html:select property =gender
html:option value=mm/html:option
html:option value=ff/html:option
/html:select
ofcourse, in the database you should have the values f or m
Are those typos in your jsp?
===htrml
If so, that may be part of the problem...
Also, I'd check to verify that the values are not padded (i.e. CHAR(2)
datatype may yield m instead of m which is not the same value.
-Original Message-
From: Goldy J [mailto:[EMAIL PROTECTED]
Sent:
How about if You try with this code in formbean
Public String getGender()
{
return gender;
}
public void setGender(String gender)
{
this.gender=gender;
}
-Original Message-
From: Goldy J [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 4:38 PM
To: [EMAIL PROTECTED]
I use the html:options tag :
Just create a Collection (here gender of the Databaseentries (f,m) and
pass as a bean to the page
with the form.
html:select name=yourForm property=gender
html:options collection=gender property=id
labelProperty=description/
/html:select
If you need more
This is what I have found works best.
On the form have a ArrayList of the dropDown elements you want.
And in the action, when preparing the data, get THE list from DB and populate it in
form.There is something called LabelValueBean in stuts or Scaffold packaage if you
want to use label value
I don't know if it's a best practice or not, but what I do is have the link
to the edit screen actually point to an action, which is responsible for
initializing any related collections and storing them in session-scoped
attributes.
A related approach would be to use the logic:notPresent tag to
, June 10, 2003 7:44 AM
To: Struts Users Mailing List
Subject: Re: Populating Drop-down
I don't know if it's a best practice or not, but what I do is have the link
to the edit screen actually point to an action, which is responsible for
initializing any related collections and storing them
Message-
From: Poon, Johnny [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 9:56 AM
To: 'Struts Users Mailing List'
Subject: RE: Populating Drop-down
Mark,
I'm glad you asked the question, caz' I was wondering about the same thing.
I'm using label/value. This is what I'm doing.
I'm
the populated
form in the request?
Thanks.
JP
-Original Message-
From: Kandi Potter [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 9:22 AM
To: Struts Users Mailing List
Subject: RE: Populating Drop-down
Hi Johnny,
I'm also using label/value vectors.I don't hard-code the form-name
List'
Subject: RE: Populating Drop-down
Hi Kandi,
Thanks for the post. I'm pretty new to actually using strut, I understand
you mentioned Struts will look for the bean in request scope and use it if
it exists, but I guess I'm not sure if I get where you actually do the
dropdown form population
someone else has replied, but just some more hints.
You can look at html:optionsCollection which as
support for labelValueBeans.
The idea about using using the tiles:controller is an
excellent one, but I have not done this.
You will probably want it in application context and
not load them all
12 matches
Mail list logo