File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Checking Checkbox values in indexed form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checking Checkbox values in indexed form" Watch "Checking Checkbox values in indexed form" New topic

Checking Checkbox values in indexed form

Vili Leonardo

Joined: Mar 12, 2004
Posts: 18

I have a problem with checking checkbox value submitted from indexed form. The jsp displays a list of items, each list has a checkbox, so it goes like this:

<form-bean name="PartItemForm" type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="part" type="com.leonardo.oms.PartItem[]"></form-property>

When this form is submitted, all the checkbox values always have "false" value even though I have selected some of the checkboxes.

I have seen these comments from the mailing list, but none helps me:
1. Have to set the checkbox in the reset() method, but In my case I don't have a form file since I defined the form declaratively in the struts-config file.
2. Use boolean type for the checkbox. PartSelected property is a boolean type.
3. Use a hidden field, then I am gonna have to use javascript to set the hidden value everytime user clicks that checkbox.

I am sure this is a pretty common web application scenarios that Struts should be able to handle.

Please give me hints on how to approach this problems.

Melanie Liu

Joined: Jun 21, 2004
Posts: 1
<form-property name="part" type="com.leonardo.oms.PartItem[]"></form-property>

name="part" should be changed to name="partSelected" in the above line.

But I didn't test this...
I agree. Here's the link:
subject: Checking Checkbox values in indexed form
It's not a secret anymore!