• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding html:checkbox

 
johny sil
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic