|
Groovy and Grails is Really Groovy |
|
|
|
|
Written by Erich Leipold
|
|
Wednesday, 11 March 2009 22:36 |
|

I just went to the Cleveland Java Users Group and Chris Judd gave a presentation on Groovy and Grails. It was a very good presentation. I can see why people are excited about Groovy. So I got home tonight and, much to my wife's dismay, I set a goal to download and create a simple order entry application for sausage orders in 1 hour. I was wrong. It took me 30 minutes to download Groovy and Grails, setup my home environments, create the application, create a single domain object (Orders), create a controller, add properties to the domain object, and modify the controller to automatically build the CRUD objects. Here are my steps:
- Go to the Groovy site and download the latest distribution.
- Extract the archive to your filesystem.
- Add the Groovy bin directory to your PATH environment variable ($HOME/groovy-1.6.0/bin).
- Go to the Grails site and download the latest distribution.
 - Extract the archive to your filesystem.
- Set the GRAILS_HOME environment variable to the installation directory for you Grails extract (i.e. $HOME/grails-1.1).
- Add the Grails bin directory to your PATH environment variable ($HOME/grails-1.1/bin).
- Make sure that your JAVA_HOME environment variable is set.
- Create a workspace directory on your filesystem ($HOME/workspace).
- Change directory to the workspace directory.
- Create the project (grails create-app sausage-orders).
- Change directory to the project directory.
- Create the domain object (grails create-domain-class orders).
- Edit the domain object (grails-app/domain/Orders.groovy) and add the following variables inside of the class:
Date dateCreated Date orderDate int quantity String units String flavor String name String phone String email - Add the following code inside of the constraints block:
units(inList:["lbs", "3-lbs"]) flavor(inList:["regular", "hot"])
- Create the controller (grails create-controller orders).
- Edit the controller (grails-app/controllers/OrdersController.groovy) and change index = {} to scaffold = true.
- Run the application (grails run-app).
That's it! Go to http://localhost:8080/sausage-orders. It's a simple application, but it works and it's a little more interesting than a hello world app.
|
|
Last Updated on Wednesday, 01 April 2009 13:58 |