• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

pagination when page refresh

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i have a problem with pagination while refresh.

Assume i have 100 records in database.Each time i will display 20
records.When i click next button i will display next 20 records.
If i am in page 2 and i refresh the page,it is going to page 3.
But it should stick to page 2 only.
This is because refresh is nothing but submitting request.
Here i am setting a command variable as "next" and passing page no.
So when i refresh, as the command is next it is submitting the page.

How to achieve this.

Thanks
siraj.
 
Ranch Hand
Posts: 225
Spring Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assalam Alekum Siraj Baig,

As you said,you want to show your next page while refreshing your page.
For that you can tell your servlet that the refresh button is pressed(through some javascript code etc) and your servlet will decide what to do in that case(i.e show the next page).
As you are setting command "next" and page no, you can increase the page no by 1 when refresh button is pressed in your servlet.

Well,remember that,when you refresh the page,the same request is submitted again.



Regards
Baseet Ahmed


Request to ALL:
"Do worship The Creator,not the creation."
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There really is no way to tell the server that the refresh button was pressed with Javascript.

Instead of sending 'next', why not change your logic to send a page number that only increments when the user explicitly clicks the "Next Page" button?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Use a boolean variable on click of the next button. Check the boolean variable in javascript. If it is true then only allow the page to go to next page. Hope this helps.
 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am already passing boolean variable to my servlet where i am
incrementing my page no.
in the jsp i am taking a hidden variable and passing this variable to
my servlet when i click next button.
Now when i refresh i am checking for this variable.But the variable
also becomes true for refresh.

Thanks,
siraj
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you pass the page no to servlet ? is it by passing as query string such as (something?next=2).

When you click on next button then are you submitting the page with incremented page no value as query string or make use of hidden parameter of the page?


LDR.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
There really is no way to tell the server that the refresh button was pressed with Javascript.

Instead of sending 'next', why not change your logic to send a page number that only increments when the user explicitly clicks the "Next Page" button?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am facing the exact problem when doing refresh on pagination.
I am using spring in my application.Do any one has any idea regarding this.please help.


Deepa Shahi
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic