Format taglib ver. 1.5


    Custom JSP taglib used to format strings according to the given pattern. For example:
 


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

<f:formatString pattern="(###) ###-####">0959392359</f:formatString>

and you will get the following: (095) 939-2359

Tag uses the following pattern syntax:

The '#' character will be replaced by the next character in the string getting formatted. Other characters will be treated as literals.

The '*' character will display all characters in the string at that point in the pattern. For example string "0959392359" with pattern "### *" will be formatted as: (095) 9392359

If you need to output '#' or '*' you may escape them with '$' character. To show a '$' in the result, the '$' character must be escaped too. For example string "abcd" with pattern "$$# $# ##" would result in: $a # cd

Tags are:

formatString

Body tag formats own body according to the given pattern (format). Parameters are:

1) pattern describes a pattern
2) truncate Optional parameter. Possible values are true or false. If this value is true all the characters in the data that exceed the pattern will be truncated. Otherwise they will be appended to the end of the result. Default value is false.
3) id Optional parameter. Describes a name for the page scope variable (type is java.lang.String). With id parameter tag will save result in this variable. Otherwise formatted string will be just printed.

for downloading:

Library: formattag.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: