Groovy Documentation

org.codehaus.groovy.grails.plugins.web.taglib
[Groovy] Class FormatTagLib

java.lang.Object
  org.codehaus.groovy.grails.plugins.web.taglib.FormatTagLib

@Artefact("TagLibrary")
class FormatTagLib
extends java.lang.Object

The base application tag library for Grails many of which take inspiration from Rails helpers (thanks guys! :) This tag library tends to get extended by others as tags within here can be re-used in said libraries.

Authors:
Jason Rudolph
Lari Hotari
Graeme Rocher
Since:
0.6


Property Summary
CodecLookup codecLookup

groovy.lang.Closure encodeAs

Encodes the body using the specified codec.

groovy.lang.Closure formatBoolean

Outputs the given boolean as the specified text label.

groovy.lang.Closure formatDate

Outputs the given Date object in the specified format.

groovy.lang.Closure formatNumber

Outputs the given number in the specified format.

org.springframework.context.MessageSource messageSource

static java.lang.Object returnObjectForTags

 
Method Summary
java.lang.String messageHelper(java.lang.String code, java.lang.Object defaultMessage = null, java.util.List args = null, java.util.Locale locale = null)

java.lang.Object parseStyle(java.lang.Object styleStr)

static java.util.Locale resolveLocale(java.lang.Object localeAttr)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

codecLookup

CodecLookup codecLookup


encodeAs

groovy.lang.Closure encodeAs
Encodes the body using the specified codec.
attr:
codec REQUIRED the codec name


formatBoolean

groovy.lang.Closure formatBoolean
Outputs the given boolean as the specified text label. If the true and false option are not given, then the boolean is output using the default label.
Examples:
<g:formatBoolean boolean="${myBoolean}" />
<g:formatBoolean boolean="${myBoolean}" true="True!" false="False!" />
emptyTag:
@attr boolean REQUIRED the boolean to output
attr:
true text label for boolean true value
attr:
false text label for boolean false value
attr:
locale Force the locale for formatting.


formatDate

groovy.lang.Closure formatDate
Outputs the given Date object in the specified format. If the date is not given, then the current date/time is used. If the format option is not given, then the date is output using the default format.
e.g., <g:formatDate date="${myDate}" format="yyyy-MM-dd HH:mm" />
emptyTag:
@attr date the date object to display; defaults to now if not specified
attr:
format The formatting pattern to use for the date, see SimpleDateFormat
attr:
formatName Look up format from the default MessageSource / ResourceBundle (i18n/*.properties file) with this key. If format and formatName are empty, format is looked up with 'default.date.format' key. If the key is missing, 'yyyy-MM-dd HH:mm:ss z' formatting pattern is used.
attr:
type The type of format to use for the date / time. format or formatName aren't used when type is specified. Possible values: 'date' - shows only date part, 'time' - shows only time part, 'both'/'datetime' - shows date and time
attr:
timeZone the time zone for formatting. See TimeZone class.
attr:
locale Force the locale for formatting.
attr:
style Use default date/time formatting of the country specified by the locale. Possible values: SHORT (default), MEDIUM, LONG, FULL . See DateFormat for explanation.
attr:
dateStyle Set separate style for the date part.
attr:
timeStyle Set separate style for the time part.
See Also:
java.text.SimpleDateFormat


formatNumber

groovy.lang.Closure formatNumber
Outputs the given number in the specified format. If the format option is not given, then the number is output using the default format.
e.g., <g:formatNumber number="${myNumber}" format="###,##0" />
emptyTag:
@attr number REQUIRED the number to display
attr:
format The formatting pattern to use for the number, see DecimalFormat
attr:
formatName Look up format from the default MessageSource / ResourceBundle (i18n/.properties file) with this key.Look up format from the default MessageSource / ResourceBundle (i18n/.properties file) with this key. If format and formatName are empty, format is looked up with 'default.number.format' key. If the key is missing, '0' formatting pattern is used.
attr:
type The type of formatter to use: 'number', 'currency' or 'percent' . format or formatName aren't used when type is specified.
attr:
locale Override the locale of the request , String or java.util.Locale value
attr:
groupingUsed Set whether or not grouping will be used in this format.
attr:
minIntegerDigits Sets the minimum number of digits allowed in the integer portion of a number.
attr:
maxIntegerDigits Sets the maximum number of digits allowed in the integer portion of a number.
attr:
minFractionDigits Sets the minimum number of digits allowed in the fraction portion of a number.
attr:
maxFractionDigits Sets the maximum number of digits allowed in the fraction portion of a number.
attr:
currencyCode The standard currency code ('EUR', 'USD', etc.), uses formatting settings for the currency. type='currency' attribute is recommended.
attr:
currencySymbol Force the currency symbol to some symbol, recommended way is to use currencyCode attribute instead (takes symbol information from java.util.Currency)
attr:
roundingMode Sets the RoundingMode used in this DecimalFormat. Usual values: HALF_UP, HALF_DOWN. If roundingMode is UNNECESSARY and ArithemeticException raises, the original number formatted with default number formatting will be returned.
attr:
nan String to be used for display if numberic value is NaN
See Also:
java.text.DecimalFormat


messageSource

org.springframework.context.MessageSource messageSource


returnObjectForTags

static java.lang.Object returnObjectForTags


 
Method Detail

messageHelper

@groovy.transform.CompileStatic
java.lang.String messageHelper(java.lang.String code, java.lang.Object defaultMessage = null, java.util.List args = null, java.util.Locale locale = null)


parseStyle

java.lang.Object parseStyle(java.lang.Object styleStr)


resolveLocale

@groovy.transform.CompileStatic
static java.util.Locale resolveLocale(java.lang.Object localeAttr)


 

Groovy Documentation