• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Get records in certain order from list

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using ListIterator
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic