24 Jun 2011

Grails 1.3.7 Quick Start

These are the basic steps I go through when setting up a new Grails application under 1.3.7:

grails create-app MyApp
grails create-domain-class MyDomain
grails create-controller MyDomain

MySQL

If you're going to use MySQL, download the MySQL Java connector and place the file here:

MyApp/lib/mysql-connector-java-5.1.6-bin.jar

In the DataSource.groovy file, set the the following fields:

url = "jdbc:mysql://localhost/MyApp"
driverClassName = "com.mysql.jdbc.Driver"
username = ""
password = ""

sqlite

If you're going to use sqlite, copy the following files as described on my sqlite post:

MyApp/lib/sqlite-jdbc-3.7.2.jar
MyApp/grails-app/conf/hibernate/SQLiteDialect.java

Git

Setup the Grails git plug-in and do the initial check-in.

grails install-plugin git 1.0-SNAPSHOT
grails git-init

Video on using Git and Grails - http://www.grails.org/dist/screencasts/screencast9.mov

Web Flow

With Grails 1.3, Web Flow was pushed out of the standard release into a plugin. To install the plug-in, execute the command:

grails install-plugin webflow 1.3.7/span

jQuery

To use ajax via jQuery via the grails plug, do the following. After these steps, jQuery will be used for the ajax calls inĀ <g:remoteField>, <g:remoteLink>, <g:formRemote> etc. Eric Turner has a good example of using jQuery with Grails on his blog and the sample code can be found at GitHub. There is an incomplete 14 minute YouTube video on creating a Grails application that uses jQuery.

To install the jQuery plugin type this command from your project's root folder:

$ grails install-plugin blueprint
$ grails install-plugin jquery
$ grails install-plugin jquery-ui
$ grails install-plugin jquery-datatables

This downloads and installs jquery-1.4.2.js and jquery-1.4.2.min.js under web-app/js/jquery/
The complete jQuery distribution is downloaded and installed under your project's /web-app/js/jQuery folder

Add the following line to your grails-app/views/layouts/main.gsp file:

<g:javascript library="jquery" plugin="jquery"/>
<jqui:resources />

Add the following to your grails-app/conf/config.groovy

grails.views.javascript.library="jquery"


Tags:
0 comments