File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes regarding html:checkbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "regarding html:checkbox" Watch "regarding html:checkbox" New topic

regarding html:checkbox

johny sil

Joined: Jul 11, 2006
Posts: 13

I have a multiple check boxes in jsp with same names.

My fileds are like this

checkbox itemcode itemname AddMore

When i click AddMore i get one more row like this

checkbox itemcode itemname

These fields are have same name

How to set this properties in ActionForm

Help me,

Thanks in advance
Frank Bueckert

Joined: Mar 23, 2006
Posts: 8
If I'm understanding you correctly, you have multiple checkboxes named the same. Problem with that is that Struts will probably (correct me if I'm wrong; I'm no expert) take the last one, and set the ActionForm value to that. You need to give them different names in the JSP.

The actionForm also requires a variable for each checkbox; ie: you have three checkboxes, named checkbox1, checkbox2, and checkbox3. The actionForm then requires boolean checkbox1, boolean checkbox2, and boolean checkbox3.

Don't forget to set these to false in your reset method, since HTML has a quirky way of sending checkbox values. If it's not checked, nothing is sent for that checkbox. If it IS checked, you get data. So, the default way of handling them is to assume they're false.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You need to use indexed properties for this.

Please read the following links, and if you still have questions about how to do this, let us know.

Consultant, Sima Solutions
I agree. Here's the link:
subject: regarding html:checkbox
It's not a secret anymore!