• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pagination when page refresh

 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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.
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • 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."
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
Kristipati Raghuram
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Laxmikant Ruikar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
Deepa Shahi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic