First, Last, Random taglib ver. 1.3


    Taglib provides a support for the very often used operations: getting the first (the last or the random) element from the given collection. For example:
 


<%@ taglib uri="taglib.tld" prefix="f" %>

<%
   java.util.Vector v=new java.util.Vector();
   v.addElement("1");
   v.addElement("2");
%>

first: <f:getFirst source="<%=v%>"/>
last: <f:getLast source="<%=v%>" id="A" /> <%=A%>

You can directly provide your collection for the tag or pass a name for your bean in a page (request, session or application) scope.

Tags are:

getFirst

Tag requests the first element from the given collection. Parameters are:

1) source Optional parameter. Describes a collection, iterator, enumeration or array
2) name Optional parameter. Describes a name for your bean in a page (request, session or application) scope.
3) id Optional parameter. Describes a name for the page scope variable for data (type is java.lang.Object). Without this parameter tag just prints data.

getLast

Tag requests the last element from the given collection. Parameters are:

1) source Optional parameter. Describes a collection, iterator, enumeration or array
2) name Optional parameter. Describes a name for your bean in a page (request, session or application) scope.
3) id Optional parameter. Describes a name for the page scope variable for data (type is java.lang.Object). Without this parameter tag just prints data.

getRandom

Tag requests the random element from the given collection. Parameters are:

1) source Optional parameter. Describes a collection, iterator, enumeration or array
2) name Optional parameter. Describes a name for your bean in a page (request, session or application) scope.
3) id Optional parameter. Describes a name for the page scope variable for data (type is java.lang.Object). Without this parameter tag just prints data.

getSize

Tag calculates the size for the given collection. Parameters are:

1) source Optional parameter. Describes a collection, iterator, enumeration or array
2) name Optional parameter. Describes a name for your bean in a page (request, session or application) scope.
3) id Optional parameter. Describes a name for the page scope variable for data (type is java.lang.Integer). Without this parameter tag just prints data.

for downloading:

Library: firsttag.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: