Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection manipulation

 
AshishP Gandhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the java.util.Collections class. It has methods for sorting lists.
 
AshishP Gandhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please be a little more specific..
I am not getting how to do it??
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic