Friday, August 31, 2007

Grails 0.6 Released with Rich Conversation Support (AKA Spring Web Flow)

We've just released Grails 0.6 which takes Grails even further away from its Rails-like beginnings. Thanks to integration with the Spring Web Flow project and support for Spring scopes Grails now supports rich conversations a la Seam.

The essence of it is that we have created a Groovy builder for construction Web Flows. This is both a good thing for Grails and for the Web Flow project as the current mechanism for flow definition in Web Flow is via XML which has limited expressiveness and too many angles for my liking.

An example of a Grails Flow can be seen below:

showCart {
on("checkout").to "enterPersonalDetails"
on("continueShopping").to "showCatalogue"
}
enterPersonalDetails {
on("submit") {
def p = new Person(params)
flow.person = p
def e = yes()
if(p.hasErrors() || !p.validate())return error()
}.to "enterShipping"
on("return").to "showCart"
on(Exception).to "handleError"
}
enterShipping {
on("back").to "enterPersonalDetails"
on("submit") {
def a = new Address(params)
flow.address = a
if(a.hasErrors() || !a.validate()) return error()
}.to "enterPayment"
}


Web Flow will completely manage the state transitions and Grails integrates Hibernate into the picture to make sure you get atomic conversations.

You can also encapsulate business logic inside service classes and define services as living in a particular scope:

class BookService {
static scope = "flow"
...
}

Thus allowing conversations with a particular service scoped to individual clients. It is all rather exciting stuff and extends Grails' capabilities allowing much more complex workflows.

This is not the only exciting feature in Grails 0.6. The headliners are:

* 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

Checkout the full release notes for details and download here

14 comments:

Anonymous said...

Graham,

could you not get rid of the need to quote the targets? Add a delegate which implements getProperty and just returns the property name. I do this in GraphBuilder and it seems to work well.

John

Charles Oliver Nutter said...

Congratulations! Sounds like a bangup release.

Graeme Rocher said...

@John
Yeh I thought about that, but i like the way with the current DSL a good text editor (TextMate) or IDE will highlight the quoted targets. For me they stand our more quoted. Maybe its a personal thing I dunno.

@Charles
Thanks!

Markus Jais said...

Great work. Grails amazes me with every new release. Keep up the good work.

any plans to update your book ?

Markus

Anonymous said...

@Graeme
First let me congratulate you on the release, I forgot last time:)

I take you point about the highlighting, however the proposal just makes string quotes optional. Can you write "Exception" instead of Exception at the moment?

Have you considered serialising the flow graph to dot files?

John

Graeme Rocher said...

Hey John,

Yeh we could make them optional certainly. It won't be that hard to do. And yeah the potential is certainly there to make dot files or freemind mindmaps and all sorts of formats from the builder syntax

It would be great!

Maybe after 1.0 thought :-)

Cheers, Graeme

Dmitriy Kopylenko said...

Congrats on the fantastic realease! Yeah, the up to date book would be great!

Dmitriy Kopylenko said...
This comment has been removed by the author.
Anonymous said...

Graeme, could you comment on a possible book update? Maybe for 1.0?

Niels Bech Nielsen said...

Congrats,

I congratulate you on goin beyond normal rails de facto standards and get much more into a web based application.

I have so waited for someone to push the bar. Keep up the good work.

Stephan.Schmidt said...

Excellent, excellent, excellent. This is so much more readable than other implementations. The way to go for some kinds of applications.

Peace
-stephan

--
Stephan Schmidt :: stephan@reposita.org
Reposita Open Source - Monitor your software development
http://www.reposita.org
Blog at http://stephan.reposita.org - No signal. No noise.

Graeme Rocher said...

@Anonymous - I will do a refresh of the book after 1.0. Possibly a collaboration as it took way too much time last time round ;-)

Peter said...

Congrats! The Spring Web Flow integration is really elegant, it is so much easier to read and use than the traditional Java/XML Spring Web Flow.

Kito D. Mann said...

I'm really digging the Spring Web Flow integration, Graeme. Looks very cool!