Title: Does anyone have a example to generate a drop down list?
Thank you very much, Spencer,
 
I tried it out, it is working.
 
I don't know where to put the code in the FORM, so I put it in the action class.  And I had to add this line of code in my

request.setAttribute("org.apache.struts.taglib.html.BEAN", form)

to make it working.

So where should I put the code to create the arrays?  Why did I have to put the line in?

 THanks a lot,

Joyce

 -----Original Message-----
From: Spencer Smith [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 18, 2001 11:41 AM
To: [EMAIL PROTECTED]
Subject: Re: Does anyone have a example to generate a drop down list?

 
IN FORM:
 
   // Get all xxx Values for DropDown.
   xxxDropDown[] results = profileSession.getxxxValues();   
   
   // Create the arrays for the labels and values.
   xxxLabels = new ArrayList();
   xxxValues = new ArrayList();
   
   // For each value returned...
   for (int i = 0; i < results.length; i ++)
   {
    // Add a label and a value to the corresponding list.
    xxxLabels.add(new String(results[i].getLabel()));
    xxxValues.add(new String(results[i].getValue()));
   }
 
 
IN JSP:
 
  <html:select property="selectedValue">
       <html:options property="xxxValues" labelProperty="xxxLabels"/>
  </html:select>
 
Make sure to define the xxxLabels and xxxValues as type ArrayList and import the class.
 
Hope this helps!  :-)
----- Original Message -----
From: Joyce Tang
Sent: Friday, May 18, 2001 10:28 AM
Subject: Does anyone have a example to generate a drop down list?

Assuming I have a object method returning a list of values.  Does anyone have a example to generate a drop down list?

Reply via email to