You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Will Glass-Husain <wg...@forio.com> on 2004/05/06 01:53:14 UTC

paged list tool?

Hi,

As long as you're thinking about list wrappers and new tools, any interest
in a tool for doing paged lists?  I've got a nifty wrapper class looking I
use in my projects looking for an open source home.  It's a subclass of a
list, with properties for NextPage, PreviousPage, etc.  It also handles lazy
evaluation.  (Good for situations in which you want to put the result of
database query in the context... the database call is only done when if the
list is used).

I'm not a tools user, so it'd be nice if someone wanted to collaborate to
make it fit the tools framework.  But I suspect it's close; I already use it
as an object in my Velocity context.

Here's how you code a paged list.  It's pretty straightforward.  There's a
number of other useful properties as well.

#foreach ($item in $list)
    #set ( $rownum = $list.RowOffset + $velocityCount)
    row $rownum: $item <BR>
#end

#if($list.HasPrevious)
       <a href="?offset=$list.PreviousOffset">Previous Page</A>
#end

#if($list.HasNext)
       <a href="?offset=$list.NextOffset">Next Page</A>
#end

---------------
I did a quick scan, it doesn't look like Tools has this capability.  If this
is interesting, let me know.

Best,
WILL

P.S.  Documentation (aimed at the template writer) is here:
http://www.forio.com/broadcastdocs/creating_interfaces/lists.htm#paged_lists

_______________________________________
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: paged list tool?

Posted by Nathan Bubna <na...@esha.com>.
Will Glass-Husain
> Ah, great -- missed that.  Out of curiosity, why a abstract class and not an
> interface?  Using an interface for this type of functionality gives a lot
> more flexibility.

there would be very little point to using an interface.  remember, the tools
are template-facing APIs.  templates don't care about what class they're
working with, just the methods that it exposes.  also, even if there were a
SearchTool interface, the default implementation would probably still be
abstract due to the difficulty of having a meaningful executeQuery(Object
crit) method that works for everyone.

> The properties are very similar.  (about 75% percent overlap).  A difference
> is that my PagedList implements List, so it can be accessed directly by
> #forEach.

yeah, that's cool.  also, it isn't tied to the idea of searching.

> Also, the Lazy Evaluation feature is handy in a data driven app.  Let's you
> do a "pull" approach for lists (or is it "push" - I get confused) even for

"pull" is correct :)

> those that have expensive initializations (e.g. a database query).
> Arguably, this should really be two different wrappers.  But it was
> convenient for me to combine them at the time.
>
> Let me take more of a look at AbstractSearchTool.    Is there already a
> concrete implementations?  I'll put a submission together.  Or I could just
> post the code as is for comparison.
...

looking forward to your submission... :)

Nathan Bubna said:
> > Will Glass-Husain said:
> > > As long as you're thinking about list wrappers and new tools,
> > > any interest in a tool for doing paged lists?
> >
> > yep.
> >
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/tools/AbstractSearchTool.html
> >
...

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: paged list tool?

Posted by Will Glass-Husain <wg...@forio.com>.
Ah, great -- missed that.  Out of curiosity, why a abstract class and not an
interface?  Using an interface for this type of functionality gives a lot
more flexibility.

The properties are very similar.  (about 75% percent overlap).  A difference
is that my PagedList implements List, so it can be accessed directly by
#forEach.

Also, the Lazy Evaluation feature is handy in a data driven app.  Let's you
do a "pull" approach for lists (or is it "push" - I get confused) even for
those that have expensive initializations (e.g. a database query).
Arguably, this should really be two different wrappers.  But it was
convenient for me to combine them at the time.

Let me take more of a look at AbstractSearchTool.    Is there already a
concrete implementations?  I'll put a submission together.  Or I could just
post the code as is for comparison.

WILL

----- Original Message ----- 
From: "Nathan Bubna" <na...@esha.com>
To: "Velocity Developers List" <ve...@jakarta.apache.org>
Sent: Wednesday, May 05, 2004 5:19 PM
Subject: Re: paged list tool?


> Will Glass-Husain said:
> > As long as you're thinking about list wrappers and new tools,
> > any interest in a tool for doing paged lists?
>
> yep.
>
>
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/tools/AbstractSearchTool.html
>
> :)
>
> > I've got a nifty wrapper class looking I
> > use in my projects looking for an open source home.  It's a subclass of
a
> > list, with properties for NextPage, PreviousPage, etc.  It also handles
lazy
> > evaluation.  (Good for situations in which you want to put the result of
> > database query in the context... the database call is only done when if
the
> > list is used).
>
> really?  sounds interesting.  do you think there's any way that
could/would
> improve the AbstractSearchTool?  or work with it?  i'm always open to
> improvements. :)
>
> > I'm not a tools user, so it'd be nice if someone wanted to collaborate
to
> > make it fit the tools framework.  But I suspect it's close; I already
use it
> > as an object in my Velocity context.
> >
> > Here's how you code a paged list.  It's pretty straightforward.  There's
a
> > number of other useful properties as well.
> >
> > #foreach ($item in $list)
> >     #set ( $rownum = $list.RowOffset + $velocityCount)
> >     row $rownum: $item <BR>
> > #end
> >
> > #if($list.HasPrevious)
> >        <a href="?offset=$list.PreviousOffset">Previous Page</A>
> > #end
> >
> > #if($list.HasNext)
> >        <a href="?offset=$list.NextOffset">Next Page</A>
> > #end
>
> nice and straightforward.
>
> > I did a quick scan, it doesn't look like Tools has this capability.  If
this
> > is interesting, let me know.
>
> i'm curious! :)
>
> Nathan Bubna
> nathan@esha.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: paged list tool?

Posted by Nathan Bubna <na...@esha.com>.
Will Glass-Husain said:
> As long as you're thinking about list wrappers and new tools,
> any interest in a tool for doing paged lists?

yep.

http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/tools/AbstractSearchTool.html

:)

> I've got a nifty wrapper class looking I
> use in my projects looking for an open source home.  It's a subclass of a
> list, with properties for NextPage, PreviousPage, etc.  It also handles lazy
> evaluation.  (Good for situations in which you want to put the result of
> database query in the context... the database call is only done when if the
> list is used).

really?  sounds interesting.  do you think there's any way that could/would
improve the AbstractSearchTool?  or work with it?  i'm always open to
improvements. :)

> I'm not a tools user, so it'd be nice if someone wanted to collaborate to
> make it fit the tools framework.  But I suspect it's close; I already use it
> as an object in my Velocity context.
>
> Here's how you code a paged list.  It's pretty straightforward.  There's a
> number of other useful properties as well.
>
> #foreach ($item in $list)
>     #set ( $rownum = $list.RowOffset + $velocityCount)
>     row $rownum: $item <BR>
> #end
>
> #if($list.HasPrevious)
>        <a href="?offset=$list.PreviousOffset">Previous Page</A>
> #end
>
> #if($list.HasNext)
>        <a href="?offset=$list.NextOffset">Next Page</A>
> #end

nice and straightforward.

> I did a quick scan, it doesn't look like Tools has this capability.  If this
> is interesting, let me know.

i'm curious! :)

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org