Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

vector pagination

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic