Of Templates and Ajax

On second thought, instead of cleaning up the list and show views, let’s just set them aside and create a new view that will replace them both. To do that, we’ll take advantage of Grails’ GSP templates.

GSP templates are simply chunks of GSP code in a file that begins with an underscore (_likethis.gsp). They provide an easy way to share common code across multiple pages (Grails’ use of the _form.gsp template for our create and edit views is a great example of this). You can include a template in a GSP page with the <g:render> tag, like this:

 
<g:render​ template=​"someTemplate"​ ​/>

This line would render a template called _someTemplate.gsp in the same directory as the page that it is being called from. To render ...

Get Grails 2: A Quick-Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.