Struts2 & jquery - custom pagination - how to go to page2 without hitting the db again
thanks in advance for any input. I am using struts2 and jquery in this app.
I tried to use displaytag for pagination but my tables have images and there wasn't a way I could make displaytag work with images.
So now I have custom coded pagination which uses <s:subset>
which works great so far except that I don't know how to make it go to another page.
Basically in <s:subset>
I just want to change the start attribute and then refresh my JSP. My code evaluates the start attribute correctly with a given page number.
My s:subset tag is like below,
<s:subset source="pa开发者_如何学运维geableList.pagedList" count="pageableList.pageSize" start="pageableList.start" >
<s:iterator>
I think I want to use <s:url>
to display my clickable page numbers but I'm having trouble there.
I have my page numbers in a list (which I evaluate in my action class right after my search completes), then in my JSP where I need to display the clickable page numbers, I iterate through the list, displaying the page numbers like below -
<s:iterator value="pageNumList" > | <a href='#'> <s:property/> </a> </s:iterator>
I guess I need to pass the clicked value of page number to the action class, then since the search results are in a list in the action class, without hitting the database again just display the results page with the new value of start attribute.
Any ideas how I might do that? I have been considering using a Decider attribute with <s:subset>
but maybe there is a simpler way?
Thanks again for any input.
Regards, veeCan
If you do not want to hit your DB again, cache the results of the initial query in RAM in your Action class (reference a static cache somewhere). Also, you don't have to go with a cache-all-or-nothing approach -- you can cache the first N pages and then when you near the end of the cache, fetch the rest. If you do it right, you can maintain minimum RAM footprint but preserve a snappy user experience that leverages user think time (depends on your app).
精彩评论