| Author |
how to fill a combobox with values from objects in an ArrayList...
|
hans meiser
Greenhorn
Joined: Dec 29, 2008
Posts: 22
|
|
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!
|
 |
abin awale
Greenhorn
Joined: Dec 23, 2008
Posts: 7
|
|
<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
Joined: Dec 29, 2008
Posts: 22
|
|
|
Thank you!
|
 |
 |
|
|
subject: how to fill a combobox with values from objects in an ArrayList...
|
|
|