Number taglib ver. 1.6

    Custom JSP taglib. Tag number lets you format numbers. Data will be presented as a body and format pattern as a parameter. For example:
 


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

<set:number format="0.00">25.6789</set:number>

<set:number format="#.00" id="A">25.6789</set:number>
Value is <%=A%>

Special symbols for patterns are defined in java.text package:

SymbolMeaning
0 a digit.
# a digit, zero shows as absent.
. placeholder for decimal separator.
, placeholder for grouping separator.
; separates formats.
- default negative prefix.
% divide by 100 and show as percentage.
X any other characters can be used in the prefix or suffix.
\u00A4 currency sign.
' used to quote special characters in a prefix or suffix.

Tag redNegative lets you change colors for negative numbers. Tag treats own body as a numeric value. If this value is negative (starts with -) then color will be changed to red. Otherwise tag prints own body "as it is".

Tags are:

number

Body tag. Formats number presented as a body for this tag. Parameters are:

1) format format pattern
2) id Optional parameter. Describes a page scope variable for data (type is java.lang.String). Without this parameter tag just prints data.
3) suppressNull Optional parameter. Possible values are true or false. If this value is true tag will output empty string for null values. Default value is false.

redNegative

Body tag changes color to red for negative numbers. Parameters are: none

for downloading:

Library: numtag.jar    Description: taglib.tld

 © Coldbeans      Comments?

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