| Author |
Checkboxes in Struts
|
Stas Shvabsky
Greenhorn
Joined: Feb 02, 2007
Posts: 5
|
|
Hi. I have a list of 0 or more of them assigned to the user. I need to show all sectors in the table. First column is name of the sector second one is checkbox. Checkbox is checked if sector assigned to user. So format should be like this <table> <tr> <td>Sector 1 name</td> <td><input type="checkbox" value="Sector 1 id"></td> </tr> <tr> <td>Sector 2 name</td> <td><input type="checkbox" value="Sector 2 id"></td> </tr> ... </table> How can I do it in Struts
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
I'd suggest using a combination of the <logic:iterate> tag or <c:forEach> if you prefer, and the <html:multibox> tag. Example: Suppose you have a HashMap that contains a bunch of sectors for which each entry contains the sector id as the key and the sector name as the value, and that the hashmap is stored in request scope under the name "sectors". The following code would work: When the user submits this form, your ActionForm's property "selectedSectors" will be a String array containing all the selected sector IDs. See the heading "multibox" in this link for more information on the multibox tag.
|
Merrill
Consultant, Sima Solutions
|
 |
Stas Shvabsky
Greenhorn
Joined: Feb 02, 2007
Posts: 5
|
|
|
Thank you it works
|
 |
 |
|
|
subject: Checkboxes in Struts
|
|
|