Choose taglib ver. 1.3


    Custom JSP taglib. Provides a custom tags based replacement for a chain of if operators in your scriptlets. For example, in scriptlet you may have some like this:
 


<%
  if (cond1) { some code ... }
  else
   if (cond2) { some code ... }
   else { some code ... }
%>

Now taglib lets you write some like this:
 


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

<if:choose>
 <if:when cond="cond1_expr"> some code </if:when>
 <if:when cond="cond2_expr"> some code </if:when>
 <if:otherwise> some code </if:otherwise>
</if:choose>

For example:
 


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

<% String s=request.getParameter("field"); %>
<if:choose>
 <if:when cond="<%=s==null%>"> some code </if:when>
 <if:when cond="<%=s.equals(\"1\")%>"> some code </if:when>
 <if:otherwise> some code </if:otherwise>
</if:choose>

Tags are:

choose

Describes a set of conditionally executed blocks when and otherwise. Parameters are:

1) cond describes logical condition tag's behavior depend on. Default value is true (make choose).

when

Describes one of conditionally executed blocks. Parameters are:

1) cond describes logical condition

otherwise

Describes a block for executions in case of all conditions are fail. Parameters are: none.

for downloading:

Library: choosetag.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: