Thursday, October 7, 2010

Using Tag Lib within Controllers and Services

So let's say you want to utilize the standard grails tag lib of formatNumber within your domain class, controller or service. How would you go about doing it? With the help of a blog post by Lucas Teixeira, I was able to get it working without an issue. Here is the code:

It's also simple to utilize your own tag libs as well. Here's a tag lib that I created to help with XML formatting:

So to call this tag lib in the domain class, controller or service, I just need to do the following:

Just make sure that you include the 'def grailsApplication' in the beginning.

No comments:

Post a Comment