Skip to content

Instantly share code, notes, and snippets.

@coderberry
Created October 7, 2010 22:11
Show Gist options
  • Select an option

  • Save coderberry/616004 to your computer and use it in GitHub Desktop.

Select an option

Save coderberry/616004 to your computer and use it in GitHub Desktop.
class Book {
def grailsApplication
String title
Float cost
static constraints = {
title(blank: false)
cost(blank: false)
}
def String toDisplayString() {
def g = grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib')
return "${title} costs ${g.formatNumber([number: cost, type: "currency", currencyCode: "USD"])}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment