{page.title}

Grails Multi-Region Templates

Grails allows you to easily create a view template for all the pages in your application through sitemesh. Making simple HTML tweaks to the default template works if you only have one main content region to your template. Oftentimes though you might want more than this (a content region and a sidebar region for example). Here’s how you can accomplish this.

GORM Inheritance Mapping

A really nice feature of GORM (and Hibernate) is support for inheritance in domain objects. For example if your application has different types of user accounts with specific properties then you can create distinct domain objects that inherit from a User base class that has all the common properties of a user (email, password, etc). Here’s what it might look like if you had a student user type and an admin user type:

URL Mapping in Grails

In grails you have a lot of control over how specfic controller actions are mapped to urls through the UrlMappings.groovy file. The default behavior is for the urls to look something like this: