(Quick Reference)

10 Creating views - Reference Documentation

Authors: Alejandro GarcĂ­a Granados

Version: 0.4

10 Creating views

Today, most modern web applications make strong use of AJAX and Responsive Web Design, two paradigms that enhances the user experience by making an application looks like a desktop-app in the browser. The Optimus plugin uses the Grails AJAX taglibs and the 3.0.0 version of the Twitter Bootstrap framework, a powerful tool that makes easier the generation of responsive web pages.

You can generate all the GSP files by executing the create-views command:

grails create-views [domainClass]
The plugin will generate the following files:
  • grails-app/controllers/HomeController.groovy
  • grails-app/views/home/_index.gsp
  • grails-app/views/index.gsp
  • grails-app/views/_header.gsp
  • grails-app/views/_topMenu.gsp
  • grails-app/views/_menu.gsp

Besides, the plugin will install the following templates:

  • src/templates/scaffolding/_content.gsp
  • src/templates/scaffolding/_list.gsp
  • src/templates/scaffolding/_form.gsp
  • src/templates/scaffolding/renderEditor.template

Finally, if you have a class named mypackage.Person, the plugin will generate the following files:

  • grails-app/views/person/_content.gsp
  • grails-app/views/person/_list.gsp
  • grails-app/views/person/_form.gsp

The plugin overrides some important files that could already exist:
  • grails-app/views/index.gsp
  • src/templates/scaffolding/_form.gsp
  • src/templates/scaffolding/renderEditor.template.

For this reason, use the create-views command carefully if you are working on an existing application.

You can generate each artifact with the following commands:

FileCommand
Home controllercreate-home
Index artifacts (index, _header, _topMenu and _menu)create-views-index
Templates (_content, _list and _form)install-optimus-templates
grails-app/views/person/_content.gspcreate-content-template
grails-app/views/person/_list.gspcreate-list-template
grails-app/views/person/_form.gspcreate-form-template

All these files are designed for working together, simulating a Simple Page Application that looks well in any device that supports a browser.