Solved

Struts - question on checkboxes - passing values

Posted on 2006-07-24
1
293 Views
Last Modified: 2010-04-16
Hello All,

I have got a doubt in struts.  in my searchresults jsp page, i have a column for a checkbox, along with other columns.  if i click the header column, then all the checkboxes in the column gets selected.  my question is how to get the selected checkboxes and also i have to pass some parameters while getting the selected checkboxes so that i have to use those parameters for generation of a pdf file..
can anybody guide me in this ?

thanks
0
Comment
Question by:altima4u
1 Comment
 
LVL 6

Accepted Solution

by:
Holger101497 earned 125 total points
ID: 17168794
we need some additional information about what you're doing!
How did you create the checkboxes? Which name(s) do they have?
Are you using an ActionForm or something like that?
Just show us a few lines of the JSP page where you create the form and the checkboxes...

In general, the name and value of the checkbox is sent as a parameter IF it is selected.
<input type="checkbox" name="delete" value="12345">
<input type="checkbox" name="delete" value="67890">

You can then call "String[] toDelete = request.getParameterValues("delete");

If both are checked, you get an array with two elements, if only one is checked, you get an array with one element. If none is checked, I'm not sure, I think you get null.
Unfortunately, it is very hard to find out which checkboxes are NOT selected because they don't send any data to the server...

I don't understand your question about additional parameters... You can just add them to the form as hidden fields...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question