I am having some issues with the paging i created. Most of the time for most pages it works correctly
However on certain pages if you click on the last page link showed on the screen (say we have 1 2 3 4) and i click on page 4
the last of the items are shown but it creates another bunch of page links when it should stop at 4 and go no further.
Here you are setting the count attribute for the second time. And this will hurt you only when the size of products is < 24 i.e. the actual number of records to be shown on each page...
Sorry this is an urgent issue that i really need help on. I figure the more people that see it the better.
Any help would be greatly appreciated. i did not know that crossposting was shunned upon
thanks
john
John Schretz
Ranch Hand
Joined: Sep 10, 2008
Posts: 171
posted
0
Ankit Garg wrote:I think this condition is creating the problems.
Here you are setting the count attribute for the second time. And this will hurt you only when the size of products is < 24 i.e. the actual number of records to be shown on each page...
The first count i am setting is the count per page iam am using 24
the second is the count of the array
which one should i remove?
Why exactly though would that cause a problem? Is it doubling the size by setting it twice?
First of all remove the code which I pointed out then it will run fine.
When you set the attribute for the second time, the value that was set earlier will be removed. This creates problems. Suppose the last page has 12 records. When you set count for the second time, then it will behave as if 12 records should be shown on each page. So the loop in your JSP will run double times. So if 4 page numbers should have been printed, then 8 will be displayed...
John Schretz
Ranch Hand
Joined: Sep 10, 2008
Posts: 171
posted
0
Ankit Garg wrote:First of all remove the code which I pointed out then it will run fine.
When you set the attribute for the second time, the value that was set earlier will be removed. This creates problems. Suppose the last page has 12 records. When you set count for the second time, then it will behave as if 12 records should be shown on each page. So the loop in your JSP will run double times. So if 4 page numbers should have been printed, then 8 will be displayed...
ok, just trying to fully understand
if i remove the line
then the only count attribute i will be setting is:
int count = settings.getCatItemCount(); // Which is always going to be 24
So you are saying that i should always set the count to 24?
sorry, i just wnat to understand the fix and not just fix it.
will fail. Suppose the size of products is 12 i.e. the last page has 12 records and total there are 96 records. Then total number of pages should be 4. But since you set count to 12, so itemCount / count will be 96 / 12 i.e. 8. So it will display 8 page numbers...
John Schretz
Ranch Hand
Joined: Sep 10, 2008
Posts: 171
posted
0
Ankit Garg wrote:Yes! You are right. If you change the value of count, then the calculation in the jsp
will fail. Suppose the size of products is 12 i.e. the last page has 12 records and total there are 96 records. Then total number of pages should be 4. But since you set count to 12, so itemCount / count will be 96 / 12 i.e. 8. So it will display 8 page numbers...
ok, so is the problem in the jsp or the servlet?
Should i still remove that line?
John just remove that line and then the code will run fine. The problem is in the servlet dude...
John Schretz
Ranch Hand
Joined: Sep 10, 2008
Posts: 171
posted
0
Ankit Garg wrote:John just remove that line and then the code will run fine. The problem is in the servlet dude...
lol, i hear ya. I dont want to sound stupid, i am new to jsp/ servlets, but have been a core devloper for a few years.
I just want to understand what i am fixing, so i feel i learned something in the process.