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.
Sometimes, it is not enough to parse or create XML documents. There are times when we need to edit an XML information for further processing. Below are examples on how to modify or edit existing XML document.
Parsing XML information is common to many projects. We showed int he previous post on how to parse XML documents using XmlSlurper. This post will focus on giving examples on how to parse documents using XmlParser.
One common task in an enterprise application is parsing of XML documents. This task is commonly complicated in Java with lots of plumbing code, but is fairly easy and straightforward in Groovy. Below are examples on how to parse XML in Groovy using XmlSlurper. Visit this post if you wish to parse XML using XmlParser.
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.
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.
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.