*
The moose likes Beginning Java and the fly likes Collection manipulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collection manipulation" Watch "Collection manipulation" New topic
Author

Collection manipulation

AshishP Gandhi
Greenhorn

Joined: Aug 05, 2007
Posts: 9
I need to take some records and display it on a jsp...and manipulate them like sorting / pagination
These records come through webservice.

Can you guide how should I go about it?

Can I make a class and get all data in collection and manipulate it the class when jsp page asks for sorting which is a button?

Awaiting replies.


Regards,
Ashish.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have a look at the java.util.Collections class. It has methods for sorting lists.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
AshishP Gandhi
Greenhorn

Joined: Aug 05, 2007
Posts: 9
Can you please be a little more specific..
I am not getting how to do it??
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm going to move this to our Java in General (Beginner) forum because it's not really a JSP specific question.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3415
    
  12
Have a look at the API Doc for the List interface. It includes a list of all standard classes that implement this interface. Select the most appropriate one for your needs (or write your own).

Once you have chosen your class, create an instance of it and then add your data to it.

You can then use the Collections.sort() methods to sort the data. Your data class will either have to implement the Comparable interface or you will have to use the version of Collections.sort() that accepts a Comparator instance.
[ August 09, 2007: Message edited by: Joanne Neal ]

Joanne
 
Don't get me started about those stupid light bulbs.
 
subject: Collection manipulation
 
Similar Threads
Collections / Generics
B&S:On the class Data
Records In Collection Object
Collection manipulation
I do not know