This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes To select all checkbox across all pages in an application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "To select all checkbox across all pages in an application" Watch "To select all checkbox across all pages in an application" New topic
Author

To select all checkbox across all pages in an application

kannan coding
Greenhorn

Joined: Nov 19, 2008
Posts: 12
My search action returns results as per pagination(i.e if 100 records are there, 10 records per page is displayed) and each record or a row of the search result will have a check box and it has a unique id.

Now i need select all the check boxes present in all the pages i.e if 10 pages are there i.e totally 100 records, all the 100 check boxes should be selected on click of one check box in the first page.
All the final operation(add/delete/update) should consider all these check box ids which are checked for further operations.

And if the user deselects one check box the final action should not consider that unchecked box id.

How can i proceed with this. Give me some logic for doing this.

Can i have a temp table to have the status and check box id or is there any other easy way of doing this.

Thanks in advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You'll need to use JavaScript to do this. In addition, if the checkboxes aren't all physically on the page (i.e., hidden etc.) you'll have to add logic that will simulate their submission.
kannan coding
Greenhorn

Joined: Nov 19, 2008
Posts: 12
Java script can be used if the results are in one page. Since i am using pagination logic only while requesting the next page i will get the next sequence of records from database, in that case how can i maintain all the check box values in my form.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Not a Struts question.

As I said, you'd have to simulate their submission.

One way would be to include hidden fields for all the checkboxes, even the ones that aren't being currently displayed. Another would be to create the checkboxes on submission via JavaScript given a list of all the IDs, and would reduce the browser memory footprint somewhat.
kannan coding
Greenhorn

Joined: Nov 19, 2008
Posts: 12
What do you mean by this statement "you'll have to add logic that will simulate their submission"
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I mean if you don't have actual hidden checkboxes then you'd have to create some means of submitting all the relevant values without them (the checkboxes), like a comma-separated list of IDs in a hidden text input that's then parsed by the action.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To select all checkbox across all pages in an application