Sunday, January 20, 2008

Flex on Grails: Introducing the Grails Flex plugin



I haven't touched this blog for the past months as life has been very busy since my son was born. But now it's time again, as I released the Grails Flex Plugin today.

With the plugin Grails services can be exposed as RPC remoting destinations within BlazeDS - Adobe's server-based Java remoting and messaging technology. These remoting destinations can be used in Flex rich internet applications to communicate with the server to restrieve or send data.

Great thing is you can use all nice features from Grails like reloading, GORM etc. and have a real RIA application on the front-end.

See Grails Flex Plugin for more information and a simple usage example.

24 comments:

Brian LeGros said...

This is great news. We use Flex pretty heavily and I've been dying to find an outlet to incorporate Grails into our architecture. Thanks for the hard work!

Karsten Silz said...

This is great news! I'm just in the middle of my first Grails app, and since we're a Flex shop, I'm looking forward to putting a Flex UI on top of that app in the future. :-)

Having said that, I think that Grails should move to a de-coupled view technology. What this means is that one should be able to specify whether Grails should generate, for instance, HTML views, HTML + Ajax views, Flex views and so on.

Dan Mullins said...

That looks pretty cool, are there any sample apps I could look at?

Marcel Overdijk said...

@karsten
Using the Grails plugin architecture it's possible to integrate a lot of view technologies. Flex is just an example of this. But there are already other plugins to use different view technologies like Wicket, Echo2, GWT etc. Have a look at http://grails.codehaus.org/Plugins for a full list. GSP is however the default view technology for Grails and will that will stay so I think.

@dan
There are no samples yet expect the mention exmaple on http://grails.codehaus.org/Flex+Plugin. The plugin is currently only a foundation to expose Grails services as remoting destinations within a Flex application. Next weeks I will be looking how I will proceed with plugin. You could imagine generating a simple CRUD application is high on the list as well as genering AS classes for Grails domain classes.

Keith said...

I created a demo app using a BlazeDS, Spring, Hibernate stack this past weekend. It took me 3-4 hours to get it all configured and working.

I saw this, and got the same functionality working in under an hour. Great job.

Is the Flex plugin eating the Grails exceptions? I had a Grails exception (missing method) and had all debugging turned on, but there were no exceptions in the console.

The only way I was able to find out there was an exception was to sniff the reponse using an HTTP debugging proxy (Charles), which parses AMF.

Marcel Overdijk said...

Keith,

That's what Grails and it's plugins are all about. Making life easier!

About your exception problem: I *think* the problem is not within Grails but within the BlazeDS Java adapter. If your mxml is calling a method of a remoteobject service which does not exist, BlazeDS should throw some exception.
Maybe you have to set some specific log level for BlazeDS classes? Just thinking here...

Good luck,
Marcel

Dominique Bitau said...

Hey Marcel.

What do you think about GraniteDS and the potential plugin support it should (or shouldn't) have in Grails?

rgds,
Dom.

Marcel Overdijk said...

@Dominique: Most plugins are created by the community to share functionality.

If you want you can step up and take the challenge to create a GraniteDS plugin. Other users might find it useful.

gandamaluko said...

I alredy use GraniteDS for spring integracion so I'm one of those user that would find a GraniDS plugin for grails useful :-) since I want to try grails for the service layer.

thanks

gandamaluko said...

I would like also to use a GraniteDS plugin :-)

thanks

Marcel Overdijk said...

You can try to create a GraniteDS plugin. See the Plugin developers guide (http://grails.org/doc/1.0.x/guide/12.%20Plug-ins.html) for more information.

You can as well check the source code from the Flex plugin as reference. I think the approach would be the same.

Good luck.

Dominique Bitau said...

Hey Marcel.

I wasn't implying you should write a GraniteDS plugin. I was just wondering if you had an opinion about GDS and potential future activity planned around it and Grails.
From your latest comment, I gather you rather concentrate on BlazeDS ;and that that's fair enough.

Many thanks for your work on the BlazeDS plugin, it is very useful.

We discovered Grails about a month ago and it seems it is going to become our framework of choice for further dev, even if we have to move to BlazeDS.

rgds,
Dom.

Sander said...

Great plugin!

Small issue: if i start the server using -Dserver.port=8090 then the port is concatenated to the end of the url:
http://localhost:8090/flex-test/8090

Is it possible that the web tier flex compiler detect changes inside my .mxml files and automatically recompiles?

Best regards!
Sander

Marcel Overdijk said...

@sander

Could you raise a new JIRA issue on http://jira.codehaus.org/browse/GRAILSPLUGINS about the port problem?

The webtier compiler is included in the plugin ans is only enabled by default in development mode. Is it not working for your?

Marcel Overdijk said...

@dominique

Good to hear your company will be using Grails!!

Cheers,
Marcel

Anonymous said...

Hi Marcel,
Thanks a lot for the great job.
We are using Grails and Flex on our project, and the plugin has been really useful so far.

But, now we are stuck at a point : We want to change the template file used by the flex compiler to generate the HTML file. If we were using flex alone, we would have changed the "template" property in the compiler.conf file for flex (See http://livedocs.adobe.com/flex/3/html/help.html?content=apache_4.html) to use our own template file.

But I checked and searched the flex grails plugin configs; but couldn't find any place where I can set the template file name (so that it uses our own template file, instead of the default one)

Am I missing something ?...Do you have any tips or suggestions ?

Thanks,
AJ

Marcel Overdijk said...

@AJ

The link you provided points to some configuration settings for the Apache and IIS compiler modules.

Within the Grails-Flex plugin the J2EE compiler module is included. I don't know if such a template property is availabe in this module; I can't see a compiler.conf file...

What you can do best is go to the Adobe Flex forum and ask if and how you can configure something equivalent using the J2EE compiler module.

Good luck,
Marcel

Marcel Overdijk said...

Just want to note that the plugin was recently upgraded to the latest and public release of Flex 3/BlazeDS.

Matthew Wallace said...

Marcel, Thanks so much for the plugin. I have installed and just trying to get Hello World example working.

Here is the thing I am not using the built in compiler. I like to build and debug directly from flex so in order to do this I am guessing that I need to point my mx:RemoteObject to an endpoint ? If so I am wondering what my gateway endpoint address would be?

-Matthew

Matthew Wallace said...

Ok I dug around a bit in the flex-plugin files and found the service-config.xml and noticed that it has a endpoint channel. This is the file the server uses when compiling the mxml files to a swf.

If you are a Flex Developer an you like setting your endpoint in the application and build separate then in your RemoteObject tag you can set your endpoint like this.

endpoint="http://localhost:8080/grails-app-name-goes-here/messagebroker/amf"

of course if your domain is different then you can leave out or change localhost:8080 to whatever you like.

Anonymous said...

Marcel,

Thanks for the plugin. I was able to get a prototype flex BlazeDS app working without too much trouble.

But now, my team has decided that we should use an AIR app instead of a flex app. I haven't been able to get BlazeDS to work with our server code, presumably because it is not running inside the container, and the plugin does some internal magic so that remoting-config.xml is not used.

Can you offer any suggestions?

Thanks again,
Scott

Anonymous said...

Hi Marcel,

Just added an enrty in Gilead's forum describing the issues I had when integrating Gilead with Grails+Flex plugin.

I post the link here as I think it may be useful for somebody else:

https://sourceforge.net/forum/message.php?msg_id=6826079

Thanks,

Martin Gorostegui

Anonymous said...

Is Flex plugin dead ? There are no new version since 2008, do you know why ? Thanks

Jason Blum said...

Ditto. ...Any plans to further develop and document this plugin?