Alternate Syntax For URL Mapping In Grails Saturday, May 19, 2007

One of the cool new features that was introduced with Grails 0.5 is Custom URL Mapping. The syntax for declaring the mapping looks something like this...


class MyUrlMappings {
static mappings = {
"/product/$id" {
controller = "product"
action = "show"
}

"/$blog/$year/$month/$id" {
controller = "blog"
action = "show"
constraints {
year(matches:/\d{4}/)
month(matches:/\d{2}/)
}
}
}
}

Since the release we have added support for an alternate syntax (which I happen to like) that looks like this...

class MyUrlMappings {
static mappings = {
"/product/$id" (controller:"product", action:"show")

"/$blog/$year/$month/$id" (controller:"blog", action:"show"){
constraints {
year(matches:/\d{4}/)
month(matches:/\d{2}/)
}
}
}
}

Dynamic languages like Groovy make these sorts of things really easy to support. Behind the scenes of this url mapping there there is no grammar file and no tangly parser to manage. The configuration file is plain old groovy code. Blurring the line between code and configuration files by using a DSL like this is so much easier in Groovy that it might be in a language like C++ or Java. You have got to love it. :)

Autism Visibility Continues To Increase

Dover Speedway has announced that the NEXTEL Cup race coming up there in June will be named “The Autism Speaks 400 presented by Visa”. NEXTEL Cup racing is huge here in North America and has a very large fan base. Autism Speaks is one of the largest foundations in the world that is dedicated to autism. I am happy to see them get their name on the marquee of an event like this. That can only help with awareness.

This is not the first time that autism and automobile racing have crossed paths. Jamie McMurray has an autistic niece and partnered with The Autism Society of American in 2004 when he drove the “Drive For A Cure” car. Tony Renna drove the “Cure Autism Now” car in 2003. There have been others.

It has been almost exactly 5 years since my youngest son Jake was diagnosed autistic. In those 5 years I have learned a number of things about autism and one of those things that I have learned is that there are not a lot of people who know much about autism. Awareness is increasing. That isn't because more people are reading medical journals in their free time. Aside from a dramatic increase in the number of kids being diagnosed autistic, the biggest reason that awareness is increasing is that more and more autism is showing up in the mainstream media. Recently some actors and other celebrities have been criticized for jumping on the “autism bandwagon”. These criticisms often refer to autism as the disease du jour. I don't have much to say about that except to say that raising awareness is an important part of this fight and when I see people going out of their way to help with awareness, I am happy to see that.

Cool New Features In Grails 0.5 Tuesday, May 01, 2007

Grails 0.5 was released today and this release is one of the most exciting releases yet. This release has closed the gap on a number of key features that needed to be knocked out before the coming 1.0 release. Some of the new features will be more appealing to some projects and other features more appealing to other pojects. For me some of the coolest new features added in 0.5 are Command Objects, List and Map Support in GORM and Custom URL Mappings. Hundres of JIRA issues have been addressed in this release and significant performance enhancements have been made. The development team got a whole lot done during this iteration. See the release notes for a more complete list of new features.

With the recent release of the first beta of Groovy 1.1, things continue to heat up in the Groovy and Grails communities.

This year I have been speaking at Java User Groups, internal training events and on the No Fluff Just Stuff Tour about Groovy and Grails and I am finding that folks in the Java community are really excited about both Groovy and Grails and the possibilities that these technologies bring to their projects. After a bit of time that really seemed kind of dull for the JVM, Groovy and Grails are making it all fun again and at the same time adding a lot of value to the enterprise by increasing productivity and expanding the possibilities. For example, defining a DSL using Antlr or similar technologies may not have been a realistic possibility for many applications but dynamic technologies like Groovy make things like that not only possible but simple to build. There are many many examples just like that which represent ways Groovy can help developers get their jobs done faster and more simply. Frankly, I don't think Grails would be anywhere near as compelling as it is if it weren't for all of the coolness made possible by Groovy. Grails has taken the possibilities that Groovy provides and leveraged them all over the framework to provide simple concise techniques for web application developers to use to build powerful web applications very quickly.

Grails has earned a lot of respect in the community by getting very far along in a short amount of time. While Grails applications are already being deployed in production environments, both private and public facing sites, the coming 1.0 release is going to push Grails right out there to the front of the pack. This is exciting stuff!

More to come... :)