aspose file tools*
The moose likes Servlets and the fly likes Get records in certain order from list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Get records in certain order from list" Watch "Get records in certain order from list" New topic
Author

Get records in certain order from list

shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
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

Joined: Jun 17, 2008
Posts: 39
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

Joined: Sep 30, 2008
Posts: 198
Did you tried list.get(index) ? Also this question has nothing to do with Servlets, should go to Java beginners forum.


My Blog
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
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

Joined: Jan 10, 2002
Posts: 61437
    
  67

Have you read the JSP FAQ entry on this subject?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
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

Joined: Jan 30, 2009
Posts: 528
Try using ListIterator


If you want something you never had do something which you had never done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get records in certain order from list