aspose file tools*
The moose likes Servlets and the fly likes pagination when page refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "pagination when page refresh" Watch "pagination when page refresh" New topic
Author

pagination when page refresh

siraj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 42
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

Joined: Dec 18, 2006
Posts: 224
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

Joined: Dec 11, 2004
Posts: 13410

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?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Kristipati Raghuram
Greenhorn

Joined: Apr 19, 2008
Posts: 3
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

Joined: Jul 11, 2006
Posts: 42
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

Joined: Nov 29, 2005
Posts: 23
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Sep 23, 2011
Posts: 1
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
 
jQuery in Action, 2nd edition
 
subject: pagination when page refresh