Groovy Documentation

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

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

    class FormatTagLib

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

Since:
  0.6

Property Summary
`java.lang.Object` | `encodeAs` Encodes the body using the specified codec.
`java.lang.Object` | `formatBoolean` Outputs the given boolean as the specified text label.
`java.lang.Object` | `formatDate` Outputs the given `Date` object in the specified format.
`java.lang.Object` | `formatNumber` Outputs the given number in the specified format.
`static java.lang.Object` | `returnObjectForTags`

Method Summary
`java.lang.String` | `messageHelper(java.lang.Object code, java.lang.Object defaultMessage = null, java.lang.Object args = null, java.lang.Object locale = null)`
`java.lang.Object` | `parseStyle(java.lang.Object styleStr)`
`java.lang.Object` | `resolveLocale(java.lang.Object localeAttr)`

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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

### encodeAs

    java.lang.Object encodeAs

  Encodes the body using the specified codec.
  attr:
    codec REQUIRED the codec name

### formatBoolean

    java.lang.Object 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!" />
  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

    java.lang.Object 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" />
  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

    java.lang.Object 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" />
  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.
  See Also:
    java.text.DecimalFormat

### returnObjectForTags

    static java.lang.Object returnObjectForTags

Method Detail

### messageHelper

    java.lang.String messageHelper(java.lang.Object code, java.lang.Object defaultMessage = null, java.lang.Object args = null, java.lang.Object locale = null)

### parseStyle

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

### resolveLocale

    java.lang.Object resolveLocale(java.lang.Object localeAttr)

Groovy Documentation