The trick is to have a hidden field with the same property as the 
checkboxes... then you have an array of checkbox ids that you can iterate 
through.

I had a form where I wanted to delete a bunch of rows from a table... the 
user has to select which row to delete by checking a checkbox and then 
when they click submit I iterate through the checkbox array and remove any 
values I find there from the IDs array... this gives me an array (well, a 
Collection in this case, an ArrayList to be precise) of unchecked 
checkboxes.

Understand what I mean? Hope so. Something like:

         // get the rows that have not been selected for deletion

       // first get all of the ids on the form
       Collection allRows = new ArrayList();
       for(int i = 0; i < form.getRowIds.length; i++)
       {
            allRows.add(form.getRowIds()[i]);
       }
 
       // next remove the selected ids
       for (int i = 0; i < form.getCheckedIds().length; i++)
       {
           allRows.remove(form.getCheckedIds()[i]);
       }


Heya Gosper
CSC Australia
212 Northbourne Ave, Braddon ACT 2612
Ph: +61 (0) 2 6246 8155  Fax: +61 (0) 2 62468100
MOB: 0401 611779
----------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please 
delete without copying and kindly advise us by e-mail of the mistake in 
delivery. NOTE: Regardless of content, this e-mail shall not operate to 
bind CSC to any order or other contract unless pursuant to explicit 
written agreement or government initiative expressly permitting the use of 
e-mail for such purpose.
----------------------------------------------------------------------------------------





"Amit Kumar Sharma" <[EMAIL PROTECTED]>
18/12/2003 05:07 PM
Please respond to "Struts Users Mailing List"

 
        To:     "Struts Users Mailing List" <[EMAIL PROTECTED]>
        cc: 
        Subject:        RE: Check-boxes and formbeans


what is the solution for that than ?we can't keep two array to maintain 
the
values attached....because of this limitation I had to change the complete
logic of the page...
If anybody also has encountered the same problem please do share and the
solution too.

-----Original Message-----
From: Jitesh Sinha [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 11:27 AM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: RE: Check-boxes and formbeans


that's correct...you won't be able to get unchecked checkboxes....

-----Original Message-----
From: Amit Kumar Sharma [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 10:57 AM
To: Struts Users Mailing List
Subject: RE: Check-boxes and formbeans


I had the same problem....when we do
request.getParameterValues(ARRAY_OF_CHECKBOX) the unchecked checkboxes 
didnt
appeared in the new array...only the checked ones were there.

-----Original Message-----
From: Jitesh Sinha [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 10:47 AM
To: Struts Users Mailing List
Subject: RE: Check-boxes and formbeans


you will be able to access fields with same name as an array...

-----Original Message-----
From: vasudevrao gupta [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 10:31 AM
To: 'Struts Users Mailing List'
Subject: Check-boxes and formbeans



Hi All,
I have many checkboxes with the same name in my html form. I use struts
framework. When i submit the form, will i be able to access the
checkboxes as an array in the form bean? Or should i have a seperate
field for each checkbox in the formbean?

Regards
Vasudevrao gupta


Confidentiality Notice

The information contained in this electronic message and any attachments 
to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to