Two Laptop Bag*
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checking Checkbox values in indexed form" Watch "Checking Checkbox values in indexed form" New topic
Author

Checking Checkbox values in indexed form

Vili Leonardo
Greenhorn

Joined: Mar 12, 2004
Posts: 18
Hello,

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:



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

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.

TIA
-Vili
Melanie Liu
Greenhorn

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: http://aspose.com/file-tools
 
subject: Checking Checkbox values in indexed form