File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Need help in getting check box values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Need help in getting check box values" Watch "Need help in getting check box values" New topic
Author

Need help in getting check box values

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Hi,

I am dynamically adding check boxes by iterating the certain values from the database.
My problem is that when i trying to get the values of check boxes i am not getting when submitting the form.



Please help.

Thanks
Aparna Raghavan
Greenhorn

Joined: Dec 07, 2008
Posts: 9
what is the exact problem you are facing?
Did you do it this way?
1. have different names for the check box (in the iteration you can append the id to the name )
2. retrieve the values in the action class from the request parameter (only checked box names will be there)



meehul Chopra
Greenhorn

Joined: Feb 23, 2009
Posts: 10
pankaj semwal wrote:Hi,

I am dynamically adding check boxes by iterating the certain values from the database.
My problem is that when i trying to get the values of check boxes i am not getting when submitting the form.



Please help.

Thanks


Hey Pankaj,

Have you tried request.getParameterValues("candidate_id1");
The above function returns an array which gives mulitple checkbox options seleted...
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Yes i have different check box values name as i am getting check box dyanmically.
My prblem is that i want to get the vales of chekc box in Action class.

Thanks
Aparna Raghavan
Greenhorn

Joined: Dec 07, 2008
Posts: 9
pankaj semwal wrote:Yes i have different check box values name as i am getting check box dyanmically.
My prblem is that i want to get the vales of chekc box in Action class.

Thanks



request.getParameter("name") should give you the value.... how did you try to get the value... As a first step, you can run your application on debug mode and check whether you are getting the values in the request parameter map.
i have not explored much about getting the values using request.getParameterValues("candidate_id1");
you can try that too....
meehul Chopra
Greenhorn

Joined: Feb 23, 2009
Posts: 10
pankaj semwal wrote:Yes i have different check box values name as i am getting check box dyanmically.
My prblem is that i want to get the vales of chekc box in Action class.

Thanks


Hi Pankaj,
Do all of your dynamically generated checkboxes have the same name and different values....if yes then at the server side code
you can very well use request.getParameterValues(//Name of the checkbox group//)
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Hi,

How can i get the values like request.getParameterValues("candidate_id1"); as need values in

Action class method. i.e in save method

this my jsp page and action class

my jsp page


myaction class
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help in getting check box values