Grails and smartgwt

To set up a grails and smartgwt project basically follow this great tutorial by Peter Ledbrook.
The equally useful tutorial by Josip goes one step further.

1) Create a grails project

2) Install the gwt plugin

3) Install the smartgwt plugin

4) Create a module

5) Fill in the entry point: Create the DataSource and Form Classes. Attention: If you use Josips tutorial make sure that in the function

the formWindow.setHeaderControls(HeaderControls.HEADER_LABEL, closeControl); methode is called first thing before any of the other formWindow.set(..) methods, otherwise you get am IlegalStateException.
Check if the url to the controller that are called from within your RestDataSource are correct.

6) Inherit from smartgwt

7) Generate the gsp page that holds the gwt client and move it from the web-app to the grails-app/view directory.

8) Remove the grails main.css from the layout/main.gsp  page

9) Add

<script>var isomorphicDir = "gwt/org.example.SmartButton/sc/"</script> to the main.gsp page but leave gwt/ as is!

10) Alter the url mapping so that the gsp page holding the gwt client is loaded by default.

11)  Run the compile gwt module command

12)  Fire up grails and fire up the gwt-client

Grails and GWT in IntelliJ’s IDEA: Not a valid GWT installation Error

The other day I treated myself to a license of IntelliJ’s IDEA and I am loving it especially when working with Grails projects.

When I started toying around with the GWT plugin for Grails however, I ran into trouble because apparently the GWT_HOME environment variable that I defined for the bash shell is not visible to IDEA which results in a nasty ERROR: null is not a valid GWT installation show stopper – among others.

To solve the problem I created the file ~/.MacOSX/environment.plist and edited it so that it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

In IDEA’s Run Debug configuration make sure that the include parent environment variables option is selected.
In this way any environment variable defined in the file environment.plist is passed to applications that are started from the finder such as IDEA.

Instead of defining GWT_HOME for the finder I could have added it to IDEA’s Run / Debug Configurations but the downside to this solution is that any script triggered by Run Target that depends on environment variables such as run-gwt-client would fall flat again.