Grails quickstart

August 3, 2007

A quick start guide to Grails

There was a period of time when Java developers can only envy the RoR developers for completing the day’s work by lunch time. Not anymore, for we have Grails to the rescue!

After exploring Grails for an hour, I’m really impressed by its fuss-free scaffolding. (In an hour, I had enough time to touch on the basics and to write this post. Ha ha :) ) Don’t be convinced by me, you’ve gotta try it for yourself to believe it.

Ok, first of all, we will need to install Grails, which is nothing more than just:

  • Download and unzip Grails.
  • Define a GRAILS_HOME environment variable to point to the unzipped Grails directory.
  • Add $GRAILS_HOME/bin to your $PATH.

Installation is complete!

Now let’s begin writing our very first “real-world” application. For starters, our application will help to manage seminars and registrations. Execute these steps on your shell:

  • grails create-app myapp
  • cd myapp
  • grails create-domain-class Seminar
  • grails create-domain-class Registration
  • Edit myapp/grails-app/domain/Seminar.groovy:
    • class Seminar {
      String title
      Date startDateTime
      String city
      Float cost
      Boolean mealsProvided
      static hasMany = [registrations:Registration]
      }
  • Edit myapp/grails-app/domain/Registration.groovy:
    • class Registration {
      String name
      Date dateOfBirth
      String gender
      Seminar seminar
      }
  • grails generate-all Seminar
  • grails generate-all Registration
  • grails run-app

That’s all the code you need to write to set up the scaffolding! Let’s enjoy the fruits of our labour by browsing to http://localhost:8080/myapp. You’ll notice this scaffolding automatically includes:

  • CRUD functionalities for both our Seminar and Registration domain classes.
  • In the Registration data entry page, the Seminar field is rendered as a dropdown list of all Seminar objects.
  • In the Seminar data entry page, the MealsProvided field is rendered as a checkbox.

Here are some screen shots of the scaffolding:

grails2.jpg

grails1.jpg

Oh, did I mention the one hour also includes a trip to the kitchen to reward myself with a cuppa coffee? :)

For further reading, I recommend this wonderful and FREE e-book: Getting Started with Grails by Jason Rudolph


Tweaking browser appliance

August 2, 2007

Found a handy document on tweaking the browser virtual appliance: http://www.spywareinfo.com/articles/vmware/batweaks.php

Among other stuff, it covers:

  • Enabling FireFox updates
  • Discard changes after shutdown
  • Sharing files between appliance and host
  • etc…

Helix virtual appliance

August 1, 2007

Am trying out the Helix virtual appliance, which is a pre-installed Ubuntu Breezy (5.10) with SVN and Trac. Here’s a nice walkthrough: http://www.geocities.com/toepfer_c/helix