File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checkboxes in Struts

 
Stas Shvabsky
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stas Shvabsky
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you it works
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic