Last updated by admin 7 years ago

Grails 0.6 Release Notes

31st of August 2007

The Grails development team has reached another milestone and is pleased to announce the release of version 0.6 of the Grails web-application development framework. Grails is a dynamic web-application framework built in Java and Groovy, leveraging best of breed APIs from the J2EE sphere including Spring, Hibernate and SiteMesh. Grails brings to Java and Groovy developers the joys of convention-based rapid development while allowing them to leverage their existing knowledge and capitalize on the proven and performant APIs Java developers have been using for years.

Thank you to all the team members, patch contributors and users. A lot of hard work has gone into this release - we hope you enjoy using this latest installment of the Grails adventure.

New Features

  • Joint Groovy/Java Compilation
  • Spring Web Flow Integration
  • Support for Spring scopes to allow scoped services
  • Improved support for REST with automatic XML/JSON marshalling and RESTful URL mappings
  • New Config DSL for configuration not possible by convention
  • Refreshed scaffolding interface and branding
  • Support for Sitemesh inline decorators
  • Controllers can now call tag libraries as methods
  • New GSP tags
  • Massive improvements to speed of start-up time, unit tests and generation tools

New from the Plug-in community

The Grails team are not the only ones who have been busy. During the development of Grails 0.6 the following plug-ins have emerged:

  • GWT Plugin - Integrates Grails with the Google Web Toolkit
  • XML-RPC Plugin - Allows invoking Grails services via XML-RPC
  • Mondrian Plugin - Integrates Grails with the Mondrian open source Relational OnLine Analytical Processing (OLAP) engine
Checkout the Plugins page for more Grails plug-in options

New Features

Joint Groovy/Java Compilation

Grails will now jointly compile all Groovy and Java sources meaning Java sources can reference an Groovy class. Java sources are also now fully reloadable at runtime meaning less server restarts.

Spring Web Flow Integration

Grails can now be used to construct stateful flows thanks to integration with the Spring Web Flow project. Grails includes a special Web Flow DSL that allows construction of flows within any controller:

class BookController {
   …
   def shoppingCartFlow = {
       showCart {
           on("checkout").to "enterPersonalDetails"
           on("continueShopping").to "displayCatalogue"
       }
       …
       displayCatalogue {
            redirect(controller:"catalogue", action:"show")
       }
       displayInvoice()
   }
}
Grails integrates Hibernate with Web Flow to allow a single session to be bound for the scope of the conversation thus allowing transactional conversations with support for optimistic locking.

Support for Spring scopes in Service classes

Grails services now support Spring scopes including integration with Web Flow scopes. For example a service class can be "flow" scoped and maintain state between client and server:

class BookService implements Serializable {
     static scope = "flow"
}
Other supported scopes include "prototype", "singleton", "request", "session", "flash", "flow" and "conversation". The latter three require an active Web Flow. See above.

REST and XML Web Services

Grails 0.6 includes improved support for REST via URL Mappings. A URL mapping can define an action to dispatch to per HTTP method:

mappings {
  "/books/$id?" {
      controller = "book"
      action = [GET:"list", DELETE:"delete", POST:"create", PUT:"update"]
  }
}
In addition, new functionality to allow easy conversion to XML or JSON has been included (originally these features were available via the Converters plugin):
import grails.converters.*
...

def list = { def items = [Book.list()] // or def items = Book.list() as Book[] render items as XML // or render items as JSON }

Unified Centralized Configuration DSL

Grails 0.6 introduces a new Config DSL for dealing with configuration not possible by convention. The same DSL is used to configure data sources, log4j and any other config needed for plug-ins.

The below examples demonstrates Log4j configuration:

log4j {
    appender.stdout = "org.apache.log4j.ConsoleAppender"
    appender.'stdout.layout'="org.apache.log4j.PatternLayout"
    rootLogger="error,stdout"
    logger {
        grails="info,stdout"
        org {
            grails.spring="info,stdout"
            codehaus.groovy.grails.web="info,stdout"
            codehaus.groovy.grails.commons="info,stdout"
        }
    }
}

Refreshed scaffolding interface

Grails 0.6 comes with a newly designed scaffolding interface that is more pleasing on the eye:

Support for SiteMesh inline decorators/layouts

Grails now supports the use of inline layouts through Sitemesh and GSP. Using the <g:applyLayout> tag you can apply layouts to templates, remote URLs or body content:

<g:applyLayout name="myLayout" template="displaybook" collection="${books}" />
or
<g:applyLayout name="myLayout" url="http://www.google.com" />
or
<g:applyLayout name="myLayout">
The content to apply a layout to
</g:applyLayout>

Controllers can now call tag libraries as methods

Grails 0.6 provides the ability to call tag libraries from controllers. This allows tag libraries to act as controller helpers and aids in the construction of Ajax applications:

class AjaxController {
     def updateLink = {
         def newLink = … // get from somewhere
         render link(url:newLink) // calls the <g:link> tag
     }
}

Other new GSP tags

There are also other additions to the GSP tag library including <g:radioGroup> that allows the easy definition of a group of radio buttons:

<g:radioGroup name="myGroup" values="[1,2,3]" value="1" >
<p><g:message code="${it.label}" />: ${it.radio}</p>
</g:radioGroup>
And tags to perform formatting of dates and numbers:
<g:formatDate format="yyyy-MM-dd" date="${new Date()}"/>
<g:formatNumber number="${myNumber}" format="\\$###,##0" />

Other improvements

  • Pre-compilation of Groovy sources for faster start-up times
  • Grails when deployed as a WAR is fully compiled into byte-code with no non-binary sources in the WAR making Grails more suitable for product development
  • More things are reloadable including data sources, spring configs, hibernate configs etc.
  • Better Eclipse/IDE integration thanks to an more intelligent main class that performs Grails packaging
  • Upgraded embedded container to Jetty 6