jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [PROPOSAL] Collections taglib
Date Mon, 22 Apr 2002 07:24:44 GMT
I guess some folks might find this useful but it does strike me that most of
these seem like simple functions to me; collection.size(),
collection.clone(), Collections.sort() and so forth. I think I'd prefer to
have a special EL that allowed methods to be called ;-)

Though the tags to create collections look very useful. A prefix of 'coll'
or 'collection' would seem more appropriate than 'data' which is a bit
vague.

James
----- Original Message -----
From: "Shawn Bayern" <bayern@essentially.net>
To: <taglibs-dev@jakarta.apache.org>
Sent: Sunday, April 21, 2002 5:16 PM
Subject: [PROPOSAL] Collections taglib


> I mentioned this once before, but now that I have more time, I'd like to
> explore it a little further.
>
> Is there any interest for a taglib that manipulates objects from the Java
> Collections API?  JSTL's expression language lets users read elements from
> collections and iterate over them, but for more specialized operations
> (computing the size, reversing the order, and so forth), users are on
> their own.
>
> While I was waiting for a session to start at JavaOne, I drafted up a
> preliminary interface. Two questions, then --
>
>  - Any interest in this, or is it pointless?
>  - Does the interface (tag set) look reasonable as a starting point?
>
> ===
>
> <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>
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
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