Pages

Groovy and some Griffon experiments

Groovy is dynamic with its superset java syntax to have fun with and be productive.It can be compiled to bytecode in .class and interpreted at runtime as a script.Adds closures,dynamic typing (duck), auto imports,no semicolon,no return... like a ruby-fied java.There can came railing Grails.Griffon for desktop, is very similar to developing web applications with Grails, basically the MVC + "convention over configuration".In Griffon, the Model is a POGO,the view is SwingBuilder and the controller (injected to) manage the Model and View together ().We know the applet coding and managing is cumbursome, for eg an applet form populated by an OrderDO etc.The coupling of model logic along with the applet controllers is mostly seen in web applications.So I decided to have some fun on this cute creature,Griffon.

A quick work around to display a bindable xml to the text area.I tried with tables, but some issues with events, so I will try later.Developing is easy and with less code.Scripting makes a flexible (agile) application layers like views and controller.Groovy can act as a super glue for different layers.It could combine XML parsing,widgets,networking...Each widget node written in the view classes is syntactically a method call.All of these method calls are dynamically dispatched.Most don’t actually exist in bytecode.Child closures create hierarchical relations.Closures are first class objects.This hierarchy of components would normally be created through a series of repetitive instantiations, setters, and finally attaching child to its respective parent.Child widgets are added to parent containers.
Like a ScrollPane having a text area etc.An event listener method is equivalent to adding a listener with that method; actionPerformed : { ... } ;in Groovy.

For this same Java does as

button.addActionListener(new ActionListener() {
void actionPerformed(ActionEvent evt) { ...}
})

Samples



source
Download source
Follow the quickstart guide and run the app from griffon-test directory

Groovy rocks!! says http://onestepback.org/articles/groovy/index.html

More here
http://groovy.codehaus.org/Griffon+Quick+Start
http://groovy.codehaus.org/Swing+Builder
http://griffon.codehaus.org/

No comments:

Post a Comment