• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get records in certain order from list

 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I have a list with 30 records each with an Id from one to 30. What I want to do is when a user selects record no. 20, I want to get 10 records before record 20. Psudo example below:

-> User selects records number 21
-> Get records 11 to 21.

my list:


Ive tried to come up of a way but they didnt work..
 
John Robert
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,



according to the sun api there is no add method for array list, which can add a number. If you already have a ArrayList of these 30 records and want to extract 10 of them to a new arraylist then may be you should iterate the list containing 30 records and add the 10 records you need in a new list.But to do this, your records need to be indexed previously . Can you explain a little more about your problem...
[ October 15, 2008: Message edited by: John Robert ]
 
Vinod K Singh
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you tried list.get(index) ? Also this question has nothing to do with Servlets, should go to Java beginners forum.
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it does have something to do with servlets. Basically, I am creating a paginating system. The user has records and he can go through 50 records at a time. What Im trying to code here is the "previous page link". If the user clicks the previous link it should load the last 50 records. I dont know where to start on this issue. I have tried several concepts but none of them work as they should.
[ October 15, 2008: Message edited by: shaf maff ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the JSP FAQ entry on this subject?
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The problem is I am handling data from a session and not requesting it from the server, so its more complex. I have managed to come up with a solution that works though after hours of head scratching.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using ListIterator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic