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

vector pagination

michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
I want to do pagination for jsp and planning to use vector for it. After I put all the data into the vactor, I not sure how to proceed. Should I use IndexOf method for vector? For example I want 20 records in a page so i should do something like below.
for(x=0, x<=myvector.lastIndexOf(), x=x+20){
(for i=0, i<=x, i++){
myvector.indexOf(i);
}
}
Is it correct? Or maybe someone have a better idea.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 639
Rollin,
Im not sure If there is any method called indexOf(int);which accepts int argument.
And I guess for your requirement you can use elementAt(int index);which will return you java.lang.Object. So you need to cast it to appropriate Class.
Hope this Helps
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30776
    
157

Rollin,
Also, you only need one loop. Since you are only displaying one page at a time, you can loop through just the correct 20 elements.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Will using third party components such as those in jsptags.com increase the performance such as becoming faster compared to vectors?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
I guarantee you that the operation of Vector will never be significant in the speed of any servlet. Look at the source code for java.util.Vector - it is a really simple class.
Bill
[ March 01, 2004: Message edited by: William Brogden ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: vector pagination