• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to fill a combobox with values from objects in an ArrayList...

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I know how i can fill a radiobutton if i have a ArrayList filled with Strings:

in my Action class i make the ArrayList, an fill it:

priority = new ArrayList();
priority.add("niedrig");
priority.add("mittel");
priority.add("hoch");

and in my JSP i use the command:

<s:radio label="Priorit�t" name="priority" list="priority" />


this generates automatically a radiobutton for each value in this ArrayList.

For my combobox its working aswell if i have Strings in the Array List.

But how can i access values of an Object in an ArrayList?

I have a ArrayList full of Category Objects. Now i would like to make a combobox with the CategoryDescription of each Object in the ArrayList.

Thanks for your help!
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<html:select name="Category"
property="selectedCategoryDescription">
<html ption value=""></html ption>
<html ptions name="Category"
property="categoryDescription"/>
</html:select>

Let me explain this:
--> drop down box/ combo box in struts should be inside <html:select> or
in your case <s:select>
--> after selecting you have to save that selected value,
Here I am saving into Category's property/attribute
selectedCategoryDescription(I assumed it).
(Please customize it according to your need)
--> <html ption value=""></html ption> is where you keep default value
at the top
eg: <html ption value="">--</html ption>
eg: <html ption value="">Select category Description</html ption>
--> <html ptions name="Category"
property="categoryDescription"/>
Here you are showing all the categoryDescription attribute of Category

Note: If you are using struts then hopefully you will be working with form beans. So customize this accordingly using form bean in your jsp page.

Hope this helps,
Abin
 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!
 
Did you just should on me? You should read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic