File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes problem paging HTML table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem paging HTML table" Watch "problem paging HTML table" New topic

problem paging HTML table

Andre LeDuc

Joined: Mar 08, 2006
Posts: 7
I want to "page" (break into segments) a HTML table.

I iterate through the table entries with the JSTL <forEach> tag.

My paging logic is encapsulated in a class where I maintain the itemsCollection and the current page indexes. I have two buttons on the JSP page for the user to scroll the itemsCollection forward or backward.
The problem is that the scrolling function will skip every other scroll group. Example: There are 15 items in the collection. The table initially display items 1 thru 5. Click the Next button and items 11 thru 15 are displayed. Click the Prev button and items 1 thru 5 are displayed. Items 6 thru 10 are skipped. Moreover, this problem is intermittent. Sometimes items 6 thru 10 will display in either the forward or backward direction, but I can't predict or control when that will happen.
I'm pretty sure this is not a fault in my paging logic. I've tracked it in the debugger, and what happens when a segment is skipped is that the JSP page is never rendered. The Struts action is called again as if the page had been rendered and the Next button had been clicked, but of course that did not happen (at least there doesn't seem to be any telltale flicker of the screen as I would expect to see if the page were rendered again). My action class returns only one mapping, "Success", and that maps to the JSP page in question.
What I've tried so far is substituted JSTL's <c:url> tags for the <html:link> tags, but that made no difference. Any help?
Soumya Saha
Ranch Hand

Joined: Apr 14, 2006
Posts: 64
Hi Andre,
You can try this.

1.Take two variables as Upper and Lower Limits.Use this as Begin and End Elements(position) of ur collection.
2.Page Load Condition : Upp as 1 and Low as 5.
2.Next Condition : change the values : put Low+1 as Upp and Low+5 as Low.
3.Prev Condition : change the values : put Upp-5 as Upp and Upp-1 as Low.
4.Enable/Disable Next/Prev Buttons accordingly.

I agree. Here's the link:
subject: problem paging HTML table
It's not a secret anymore!