Archive

Archive for January, 2010

Grails and Flex nothing simple than this for Rich Web App on GAE


Most of us know by now just how easy it is to write Flex applications backed by Java and Java using GraniteDS. Adobe have done a lot of work to ensure that integration with ColdFusion is seamless. It’s very impressive.

Browsing through the Grails site, I noticed they have a plugin for Flex so I figured I’d try it out.

Following the instructions, I installed the plugin (grails install-plugin gdsflex) which took a fair while to fetch the plugin from the codehaus.org site and build it and install it into my project. Then I created a service class – a regular Groovy class – with just this one additional line:

static expose = [ ‘flex-remoting’ ]

It had a method, hello(), that returned a string.

Then I put my main.mxml file in the web-app directory of my Grails project with these lines inside the mx:Application tag:

<mx:RemoteObject id=“ro” destination=“homeService”/>

<mx:Button label=“get Address!” click=“ro.homeAddress()”/>
<mx:TextInput text=“{ro.homeAddress.lastResult}”/>

You don’t need to build the project. You don’t need to set any paths in FlexBuilder. Just create the MXML file.

Then I hit the MXML file in my Grails app:

what i had to code is:

package app
class HomeService {
static expose = [‘flex-remoting’]
boolean transactional = true
def hello() {
return “Hello World!!!”
}
def getHomeAddress() {
return “3924 Hillstead ln”
}
def getHomePhone(){
return 3344433
}
}

what i had to type :

>grails create-app home

>grails install-plugin gdsflex

>grails create-service app.Home

>grails run-app

>grails install-plugin app-engine

>grails app-engine package

>%APPENGINE_HOME%/bin/appcfg.cmd update ./target/war

>grails app-engine deploy

reference: corfield.org, http://grails.org/Flex+Plugin