You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Boulatian, Misak" <mi...@vantra.com> on 2001/01/31 17:37:27 UTC

paging for web application

Hi alI,

I am trying to implement paging for web application. The query may return
over thousand records and it is a bad idea to dump all of those to the
client. I was thinking to feed only 50 records at a time and have client to
click for next or previous page. We are using struts with EJBs. Our action
classes call session EJBs, which return information as a javabean. Does
anyone have any ideas or done anything with struts in regards to paging (it
may not even have to do anything with struts).

I appreciate any responses.
Thanks,
Misak

Re: paging for web application

Posted by Matthew Harrison <m....@inpharmatica.co.uk>.
Hi, 
we've been using the pager tags for a while on a prototype, and I'd like to
extend them with a "first" and "last" tag. We're also doing queries which bring
back many thousands of results. We'll be tuning our SQL later, but it works
fine. Did you put your results in a session attribute?

Also, I'm sure you can nest tags, but I think they have to be written to allow
the jsp compiler to interpret the body rather than just copy it. I need
desperately to get into writing tags to clean up our pages, and the pager taglib
fiddling might just be the intro I need.

As for putting the index above the results, maybe you could have an empty loop
to count the results, show the index, use the pager properties pagerOffset and
pagerMaxItems to display the just results for the current page in a second loop,
and then have a second index below. It does kind of defeat some of the logic
built into the pager tags, though, and it's a bit inefficient.
It's designed for arbitrary iterations, but it would be nice though to be able
to tell it how many things you're display without having to loop through it all,
but it seems fast enough for now. 

Matthew.

 > ----------------------------------------------------------------------
 > Date: Mon, 12 Feb 2001 15:36:05 -0700 (MST)
 > To: struts-user@jakarta.apache.org
 > From: Steve A Drake <sa...@comet.ucar.edu>
 > Subject: Re: paging for web application
 > Message-ID: <Pi...@mother.comet.ucar.edu>
 > 
 > On Wed, 31 Jan 2001, Peter Alfors wrote:
 > 
 > > check out the pager taglib:  http://jsptags.com/tags/navigation/pager/
 > 
 >  Actually, I can run the example that comes with the distribution but am
 > having some problems using this pager taglib in Struts. The links created
 > by the pager aren't working.
 > 
 >  The example I'm working on has a JSP with an embedded form that, upon
 > submission, invokes a database query and reads back the results stored in
 > request scope beans (to the same JSP). The pager creates the correct
 > number of links to result pages. For example, one link created is:
 > 
 > http://localhost/project/simpleQuery.jsp?pager.offset=1
 > 
 > But when I click on this link I only get my simple query form and the
 > pager output of:
 > 
 > Result Pages [<<Prev] 1
 > 
 > but no other results. I've also tried typing in the URL:
 > 
 > http://localhost/project/simpleQuery.do?pager.offset=1
 > 
 > with the same result (or lack there-of).
 > 
 >  Ideas? Any help is appreciated!
 >  Sorry if this is off-topic for Struts.
 > 
 > ------------------------------
 > 
 > Date: Mon, 12 Feb 2001 17:25:18 -0700 (MST)
 > To: struts-user@jakarta.apache.org
 > From: Steve A Drake <sa...@comet.ucar.edu>
 > Subject: Re: paging for web application
 > Message-ID: <Pi...@mother.comet.ucar.edu>
 > 
 > On Mon, 12 Feb 2001, Steve A Drake wrote:
 > 
 > > On Wed, 31 Jan 2001, Peter Alfors wrote:
 > > 
 > > > check out the pager taglib:  http://jsptags.com/tags/navigation/pager/
 > > 
 > >  Actually, I can run the example that comes with the distribution but am
 > > having some problems using this pager taglib in Struts. The links created
 > > by the pager aren't working.
 > 
 >  Well, I did get this working but with a couple of major caveats. 
 > 
 > 1) In order to define a given <pg:index>, I had to use scriptlets for all
 > the code between the start and end tag. I assume this is because - from
 > what someone enlightened me earlier with - you can't nest tags. I hope
 > I'm wrong about this because it significantly clutters up the JSP and 
 > renders all the bean tags unusable. =:|
 > 
 > 2) I needed to locate the hypertext index at the bottom of the document
 > because the index dimensions are determined as the results are iterated. I
 > assume this could be fixed by buffering the output to a StringBuffer or
 > somesuch but havn't tried that yet.
 > 
 > If anyone has some usage suggestions for this pager taglib, I'd
 > appreciate your input.
 > 

Re: paging for web application

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Mon, 12 Feb 2001, Steve A Drake wrote:

> On Wed, 31 Jan 2001, Peter Alfors wrote:
> 
> > check out the pager taglib:  http://jsptags.com/tags/navigation/pager/
> 
>  Actually, I can run the example that comes with the distribution but am
> having some problems using this pager taglib in Struts. The links created
> by the pager aren't working.

 Well, I did get this working but with a couple of major caveats. 

1) In order to define a given <pg:index>, I had to use scriptlets for all
the code between the start and end tag. I assume this is because - from
what someone enlightened me earlier with - you can't nest tags. I hope
I'm wrong about this because it significantly clutters up the JSP and 
renders all the bean tags unusable. =:|

2) I needed to locate the hypertext index at the bottom of the document
because the index dimensions are determined as the results are iterated. I
assume this could be fixed by buffering the output to a StringBuffer or
somesuch but havn't tried that yet.


If anyone has some usage suggestions for this pager taglib, I'd
appreciate your input.


Re: paging for web application

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Wed, 31 Jan 2001, Peter Alfors wrote:

> check out the pager taglib:  http://jsptags.com/tags/navigation/pager/

 Actually, I can run the example that comes with the distribution but am
having some problems using this pager taglib in Struts. The links created
by the pager aren't working.

 The example I'm working on has a JSP with an embedded form that, upon
submission, invokes a database query and reads back the results stored in
request scope beans (to the same JSP). The pager creates the correct
number of links to result pages. For example, one link created is:

http://localhost/project/simpleQuery.jsp?pager.offset=1

But when I click on this link I only get my simple query form and the
pager output of:

Result Pages [<<Prev] 1


but no other results. I've also tried typing in the URL:

http://localhost/project/simpleQuery.do?pager.offset=1


with the same result (or lack there-of).

 Ideas? Any help is appreciated!
 Sorry if this is off-topic for Struts.



Re: paging for web application

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Wed, 31 Jan 2001, Peter Alfors wrote:

> check out the pager taglib:  http://jsptags.com/tags/navigation/pager/

 Very handy! For anyone else looking at this for paging long-winded
result sets, and using Tomcat 4.0-b1, I needed to edit the demo
"pager-demo.jsp" and change:

<pg:pager maxIndexPages="<%= 20 %>">

to:

<pg:pager maxIndexPages="20">


This fixes a hack put in to convert "20" to an int as delineated in the
pager troubleshooting section.


Re: paging for web application

Posted by Peter Alfors <pe...@irista.com>.
check out the pager taglib:  http://jsptags.com/tags/navigation/pager/


"Boulatian, Misak" wrote:

> Hi alI,
>
> I am trying to implement paging for web application. The query may return
> over thousand records and it is a bad idea to dump all of those to the
> client. I was thinking to feed only 50 records at a time and have client to
> click for next or previous page. We are using struts with EJBs. Our action
> classes call session EJBs, which return information as a javabean. Does
> anyone have any ideas or done anything with struts in regards to paging (it
> may not even have to do anything with struts).
>
> I appreciate any responses.
> Thanks,
> Misak