jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <bay...@generationjava.com>
Subject Re: [PROPOSAL] Collections taglib
Date Mon, 22 Apr 2002 08:10:09 GMT

Just a few comments that are occuring to me.

Why restrict it to collections? Why not allow it to seamlessly deal with
maps, arrays, iterators, enumerations all at the same time?

You have it specifying 'map|list|set', I've never quite got this one. Why
not:

keyed|ordered|unique

The map/list/set system completely hides the fact that these are mutually
compatible. I might want an ordered keyed collection [SortedMap/ListMap]
or an ordered unique collection [OrderedSet/TreeSet]. I might also want an
attribute with:  optimise="read" or optimise="write" to help with the
choosing of the actual implementation.

Basically, why show the java implementation, why not just offer up
features which can be mutually compatabile. Then use Commons Collections
to fill in any gaps, SortedMap etc.

With comparators, it would be nice to be able to say:

comparator="Numerical" or some such. Then the parameters in the tld could
list the standard comparators. These would again come from Commons, but be
addable to by the developers.

Aside from that, I agree with James' remark about the data name. I can
live with the collection name, though I find it a bit painful.

struct!

Just kidding.

By allowing the taglib to be loose with regard to the type of structure
underneath, and by hiding the implementation with feature requests, I
think the taglib would offer up a face that didn't involve having to get
to grips with the nitty gritty, and therefore be a good thing.

Hen

On Sun, 21 Apr 2002, Shawn Bayern wrote:

> <data:copy var="new" collection="old" />
>   // copies the collection, which is useful if you suspect it will change
>   // or if you're going to modify it yourself
>
> <data:size var="size" collection="c" />
>   // computes and exposes the size of the collection
>
> <data:sort var="new" collection="old"
>    [order="ascending|descending"]
>    [comparator="c"]
> />
>   // sorts the collection
>
> <data:reverse var="new" collection="old" />
>   // reverses the current order of the collection
>
> <data:max var="max" collection="c" [comparator="c"] />
>   // exposes the maximal element in the collection
>
> <data:min var="min" collection="c" [comparator="c"] />
>   // exposes the minimal element in the collection
>
> <data:new collection="list|map|set" [javaType="..."]>
>   // creates a new List, Map, or Set
>   // - javaType if specified must be compatible with collection
>   // - list defaults to ArrayList, map defaults to HashMap,
>   //   set defaults to HashSet
>   // - no 'collection' defaults to type suggested by subtags
>   //   (key -> Map, no key -> List)
>   // - empty <data:new> tag defaults to empty ArrayList.
>
>   <data:item [value="value"] [key="key"] />
>     // - no 'value' attribute implies String from body
>
>   <data:items collection="c"/>
>
> </data:new>
>
> <data:add collection="c" >
>   // adds the items from the subtags to the collection
>   // - subtags must have a key if 'c' is a Map, otherwise must not
>   <data:item .../>
>   <data:items ... />
> </data:add>
>
>
> ===
>
> Use cases include:
>
>   <data:reverse var="backwards" collection="${forwards}"/>
>   <c:forEach items="${backwards}">
>     ...
>   </c:forEach>
>
>   ---
>
>   <data:new var="new" scope="session">
>     <data:items collection="${c1}"/>
>     <data:items collection="${c2}"/>
>   </data:new>
>
>   // elsewhere in session
>   <c:forEach items="${new}">
>      ...
>   </c:forEach>
>
> --
> Shawn Bayern
> "JSP Standard Tag Library"  http://www.jstlbook.com
> (coming this summer from Manning Publications)
>
>
> --
> To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message