aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "regarding html:checkbox" Watch "regarding html:checkbox" New topic
Author

regarding html:checkbox

johny sil
Greenhorn

Joined: Jul 11, 2006
Posts: 13
Hi,

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

Ex:
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
Greenhorn

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.

http://struts.apache.org/1.2.9/faqs/indexedprops.html

http://wiki.apache.org/struts/StrutsCatalogLazyList


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding html:checkbox