O'Reilly logo

Grails 2: A Quick-Start Guide by Ben Klein, Dave Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Display Message Threads with a Custom Tag

Now we need to add nesting to our message list in order to visualize the various threads in our forum. We’ll do this with a custom GSP tag. If you’ve ever written custom JSP tags or JSF components, come out from under the table. It’s not like that at all. But just to reassure you, before we get started on our custom tag, we’ll take a brief look at what it takes (or more important perhaps, doesn’t take) to create a GSP tag.

A Brief Introduction to GSP Tags

The first step is to create a TagLib. A TagLib is a Groovy class with a name ending in (surprise, surprise!) TagLib, and it lives in the grails-app/taglib directory. Grails provides a convenience script to create this for us:

 
$ ​grails create-tag-lib ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required