Grails Cookbook - A collection of tutorials and examples

Grails formatNumber Tag Example

The Grails' <g:formatNumber> tag can be used inside GSPs to control the format when displaying numerical values. This is based onJava's DecimalFormat or the JSTL formatNumber tag. Below are some examples on how to use this tag.

Grails formatBoolean Tag Example

The Grails' <g:formatBoolean> tag can be used to format boolean values for rendering inside GSP view page. Here are some examples on how to use this tag.

Grails formatDate Tag Example

The Grails' <g:formatDate> tag can be used inside GSPs to format java.util.Date instances for display. The tag is based on Java's SimpleDateFormat class. Below are some examples on how to use this tag.

Grails elseif Tag Example

The Grails elseif tag (<g:elseif>) tag is used together with the if tag (<g:if>) and optionally with the else tag (<g:else>). The elseif is used if there are more than one test that needs to be performed. Here is a simple example on how to use this tag.

Grails else Tag Example

The Grails else tag (<g:else>) tag is used together with the if tag (<g:if>). The else portion is rendered when the if part failed. This is used to have conditional statements inside a GSP. This is useful if we want to display a certain view code or another depending on some condition. here is a simple example on how to use the Grails else tag.

Grails datePicker Tag

The datePicker tag (<g:datePicker>) can be used to render an HTML for date input. It may render the input components for the day, month, year, hour and second. What is rendered can be controlled depending on parameter used. here are some examples:

Grails createLinkTo Tag Example

The Grails createLinkTo Tag renders the path or url to a static resource. For example: css, images, and javascript files. This does not render an anchor tag or image tag to the resource, but just the URL that can be used inside others tags, JavaScript, etc. Here are some examples

Grails createLink Tag Example

The Grails createLink Tag renders the necessary path or url to a resource depending on the given parameters. This does not render an anchor tag, but just the URL that can be used inside an anchor tag, JavaScript, etc. Here are some examples

Grails findAll Tag Examples

This will show examples on how to use the Grails findAll tag(<g:findAll>). This tag is similar to each tag and uses the Groovy JDK findAll method to iterate over each element of a collection and only renders the body if the attribute "expr" is evaluated to true.

Grails join Tag Examples

This will show examples on how to use the Grails join tag (<g:join>). This tag utilizes the Groovy join method to concatenate the toString() representation of each item in a list or collection. A custom separator can also be used for this tag.