Hi,

Take a look at the TICL (Tag Interface Component Library) GUI toolkit - 
http://www.kobrix.com. There's a server-side component there called 
TableView that has a pager (creates page numbers and navigation for next 
and previous sets of pages) and in general manages paging state for you. 
Your provide the data to the component in a table model and there are 
predefined table models for SQL records, bean collections and Swing 
table models. Check out the TableView DB example on the site.

BTW, we just released the 1.0 beta of the product so any feedback is 
VERY MUCH appreciated ;)

Cheers,
Boris

Soefara Redzuan wrote:

>>> Hmmm...this is one of the most frequently asked for options on the
>>> JSP-Interest mailing list.  You'd think there would be an option 
>>> like this
>>> in the Jakarta taglibs.  Is there a way to do this in JSTL 1.0?  If 
>>> not,
>>> could this be in JSTL  1.1?
>>
>>
>> In JSTL 1.0 you can do it in two ways:
>> 1) Get all rows with <sql:query> and save the Result in the session
>>    scope. The loop through a subset per page, using the "begin" and
>>    "end" attributes of the <c:forEach> action.
>> 2) Get only as many rows as you want to display per page using the
>>    "startRow" and "maxRows" attributes of <sql:query>, and display
>>    the complete subset with <c:forEach>
>>
>> 1) is efficient if the max number of rows is small enough to not
>> exhaust the memory (in some cases you can even cache the data in
>> the application scope instead of the session scope).
>
>
> I think this method is too inefficient for anything more than 2 pages 
> of results. Wasteful to look up too many records.
>
>> 2) may work better when the potential number of rows is very large,
>> but be aware that when "startRow" is used, all rows up to "startRow"
>> are in fact retrieved from the database and thrown away.
>
>
> We still have the issue of how to create the page numbers at the 
> bottom of the page.  1-2-3-4-5-6-7-etc for the different pages.
>
>> Option 3), is to use an SQL statement that gives you only the
>> subset you want, e.g. using a WHERE clause like
>>
>>   Index >= startRow AND Index < startRow + maxRows
>>
>> The tricky part is to find a column that can be used as a good index.
>
>
> If using mysql, you can use SQL LIMIT. It's much easier.
>
>    "select * from tablename where .... LIMIT 10"
>
> limits the results to the 10 rows.
>
>    "select * from tablename where .... LIMIT 10, 200"
>
> limits the results to rows 200-210.
>
> Soefara Redzuan.
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
>
> -- 
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
>
>
>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to