You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Chen, Dean (Zhun)" <De...@gs.com> on 2002/10/01 17:45:57 UTC

pagination & session scope issue

Hi,
I'm currently using Pager from JSPTags.com to do pagination. However, I'm
running into problems because it requires the data  to be kept in session
scope. Basically the problem is that if 2 windows for a single application
are open, the pagination mechanism fails because it uses the latest data in
session scope.
Is there a way around this besides going back to the database for every
pagination? 

How does big websites like amazon, google, yahoo solve this problem?? 

Thanks a lot.

Dean Chen

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: pagination & session scope issue

Posted by Brandon Goodin <ma...@phase.ws>.
if your data doesn't need to be live all the time... cache it and set an
appropriate timeout. I wrote a simple caching mechanism that works great.

This will reduce database lookups then you can create your pagination on the
backend with Some classes.

I have a set of classes i called Scroller,ScrollerBean, and
ScrollerPageBean.

The Scroller handles the splitting up of the List according to the page size
specified and the size of the list passed and handles all the logic for
determing the values that are stored in the ScrollerBean and
ScrollerPageBean. The ScrollerBean holds all the values for the actual List,
pageNumberList, next, nextPage, previous, previousPage, resultSize, etc. The
ScrollerPageBean holds data specific to each page (i.e. pageLabel,
pageValue, isSelected). Oh, also the Scroller does not return the whole List
of objects to the page. It trims it down to the appropriate subList of the
cached results.

Scroller - populates ScrollerBean and ScrollerPageBean

ScrollerBean - contains shared values for paging and contains a collection
of ScrollerPageBeans
	properties:
	* int next - nextPage Number
	* boolean isNext - is there a next page
	* int previous - previous Page number
	* boolean isPrevious - is there a previous page
	* resultSize - this holds the total result size of the initial result set
	* List objects - A list of beans usually generated from a recordset to bean
list translation
	* List scrollerPageBeans - A list of page values for generation of page
list (ex 1 2 3 4)

ScrollerPageBean - contains page specific paging values
	* int pageNum - array location of page Number to be passed back when the
page is selected
	* int currPage - viewable page number (pageNum +1) so if pageNum is 0 (the
index in the List) then the currPage would be 1
	* boolean selected - a boolean indicating if this is the current page being
viewed.

All of this is then passed to the page where you can easily use tag libs to
produce a page list.

Brandon Goodin
Phase Web and Multimedia
P(406)862-2245
F(406)862-0354
http://www.phase.ws

-----Original Message-----
From: Chen, Dean (Zhun) [mailto:Dean.Chen@gs.com]
Sent: Tuesday, October 01, 2002 9:46 AM
To: 'Struts Users Mailing List'
Subject: pagination & session scope issue


Hi,
I'm currently using Pager from JSPTags.com to do pagination. However, I'm
running into problems because it requires the data  to be kept in session
scope. Basically the problem is that if 2 windows for a single application
are open, the pagination mechanism fails because it uses the latest data in
session scope.
Is there a way around this besides going back to the database for every
pagination?

How does big websites like amazon, google, yahoo solve this problem??

Thanks a lot.

Dean Chen

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>