Feature Requests item #1013526, was opened at 2004-08-21 20:23
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=536616&aid=1013526&group_id=73068

Category: main taglib
Group: after 1.0
Status: Open
Resolution: None
Priority: 5
Submitted By: Will Glass-Husain (wglass)
Assigned to: Nobody/Anonymous (nobody)
Summary: Increase efficiency paging using a subset (alternate impl)

Initial Comment:
[This really belongs in issue#872183 but I couldn't figure 
out how to add another file to the issue.]

The dilemma - how to efficiently display a large list (e.g. 
20,000 rows) one page at a time.  Currently, to take 
advantage of DisplayTag's paging features, you must 
generate the entire list each request.

This patch allows the application to control the 
selection of the specific sublist, with DisplayTag 
automatically generating the PREV/NEXT links as usual.  
For an MVC environment pulling large lists out of a 
database this can be used to implement significant 
performance improvements.

There's already a patch solving the same problem in the 
issue tracker (#872183), but I've made an alternate 
implementation (not having seen the first proposal at 
the time).    This particular patch may be easier to 
integrate than the previous one (being based on a more 
recent version of DisplayTag).  It is fully backwards 
compatible, works with EL tags, and is configurable with 
DisplayTag properties rather than any new attributes.

Using it is not too complicated, although it requires 
coordination between the Controller code and the JSP 
page.  There are two new DisplayTag properties:

paging.manual (true/false, default: false)
paging.manual.prefix (default "d")

In order to produce a table, the controller must 
generate the sublist, calculate the size of the full list, 
and pass both pieces of info to DisplayTag.  (both are 
required for paging).  The size of the full list is passed 
by setting a pageContext attribute with the name of "d-
size".  (or X-size, if X is the prefix specified with 
the "paging.manual.prefix" property).  DisplayTag will 
display the sublist amd will also generate page hyperlinks 
for the full list.  Each hyperlink will contain a request 
parameter "d-p", e.g. "d-p=2".  (This is similar to the 
standard page parameter which is typically something 
like "d-2911-p=2").  When the hyperlink is clicked, the 
controller should note the new page number and send 
along a new sublist.  

Example pseudo code:

CONTROLLER:

int pagesize = 10;
int fulllistsize = <count the size of the full list>
List sublist = <generate sublist for the particular page, 
based on a page size of 10>
pageContext.setAttribute("list",sublist);
pageContext.setAttribute("d-size",fulllistsize);

JSP PAGE:

<display:table name="${list}" pagesize="10">
        <display:setProperty name="paging.manual" 
value="false" />      

        .. all the display columns
</display:table>

A key issue the patch had to address is how to 
distinguish one TableTag from another if there are 
multiple instances on the same page.  This is normally 
done with an automatically generated id.  In this case 
however, since the request parameters must be 
recognized by the controller to generate the sublist, the 
id is skipped and the prefix (specified in the properties) 
is used instead.  Thus it is up to the page designer to 
use different prefixes for different DisplayTag tables on 
the same page.

I'd welcome any comments.

Note: this patch was made against nightly build of 8-16-
04, 1.0-rc2 SNAPSHOT.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=536616&aid=1013526&group_id=73068


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to