Let me walk you through a simple example. It seems that nowadays a Twitter demo is the way to go so let's follow that path. We'll build a trivial application that will query the followers of an authenticated user, these are the steps:
- First, grab a copy of Griffon 0.2-BETA (or newer) if you haven't done so already.
- Let's create the app, type griffon create-app gritter on your command prompt.
- Go into the app's directory and type griffon install-plugin rest, this will install the latest version of the REST plugin.
- Edit griffon-app/models/GritterModel.groovy by adding the following text
- Edit griffon-app/views/GritterView.groovy, add the following text
- Fetch a copy of GlazedLists and MigLayout and place them inside $basedir/lib. That should take care of all required dependencies.
- Edit griffon-app/controllers/GritterController.groovy, this is where the magic happens
The Rest plugin will inject a few dynamic methods, withRest() is one of them. This method uses a RESTClient under the covers. Notice that the Twitter request is performed outside the EDT, followers are collected on a background thread, then the model is updated inside the EDT. - Run the application by typing griffon run-app. Upon entering valid Twitter credentials you should see a similar screen like the following one
Keep on Groovying!