grails (11) vaadin (11) meteor (6) java (4) elasticsearch (3) apple (2) centos (1) cloudbees (1) google analytics (1) gradle (1) heroku (1) javafx (1) javascript (1) jdbc (1) jug (1) logback (1) logging (1) mac os (1) management (1) mongodb (1) mongolab (1) mysql (1) twitter (1) ubuntu (1)

Wednesday, October 3, 2012

Grails and Vaadin 7 beta - first version of the plugin

It is finally out. The first working version of Grails plugin for Vaadin 7.

Vaadin 7 differers from Vaadin 6 a lot and therefore there is no backward compatibility beween the plugins for 6th and 7th version. Actually, the plugin for Vaadin 7 is made almost from scratch. Many things have been simplified and plugin is just handling the connection between Grails and Vaadin. For example dynamic methods getBean and i18n are not injected anymore. 

One thing I have noticed after playing with Grails 2.2.0 and Vaadin 7 - it is fast (actually in two ways). First, I have made localized application with access to database via ORM (Hibernate) and Spring (Services), displaying list of users in a good looking table in just 5 minutes (sometimes, in other frameworks, I don't even setup the project in that short time). Second, it is really responsive user interface. I think the guys in Vaadin did amazing job with the 7th version. 

Let's have a look how to install the latest version and try it out. Setup Grails console before you start or you can just make it in your favorite IDE. 
  1. Create new project and run it.
    grails create-app bookstore
    cd bookstrore
    grails run-app
  2. You can stop the application now. It was just to verify that you have successfully created the project. Download and install the plugin
    grails install-plugin /path/to/plugin/grails-vaadin-1.7.0-beta2.zip
  3. And run the application
    grails run-app
Quite simple, right? You might be wondering... what about access to database or localization. There is a new class Grails and that one is meant to be used when you need to get the access to the services or i18n. Few examples follows.

Let's create a service class in Grails. It just returns all the users from the database.
class UserService {
   List<User> listUsers() {
      return User.list()
   }
}
Now get the service and call the method.
List<User> users = Grails.get(UserService).listUsers()

Or just create new Label and pass there localized string. 
String text = Grails.i18n("key.to.localization.from.i18n")
Label label = new Label(text)

If you find an issue, please report it in Jira or preferably in Github
TextLab for Mac
Ultimate application to validate, clean and format JSON, XML, SQL, HTML.

Grails and Vaadin 6 - few changes in the plugin

There are few changes in the plugin. You can find the changed Vaadin plugin under this version number 1.5.5
  • No configuration needed after the plugin installation. 
Previously we had to add a new class that extends Vaadin application, add a reference to VaadinConfig about that class and finally remove content of UrlMapping. This all is automated now. We just create Grails project install the Vaadin plugin and run the application.
  • Versions updated.

Grails updated to 2.2.0 and Vaadin to 6.8.4. 
Follow these steps in case you want to try it out. 
  1. First set Grails console
  2. Create new Grails project and try to run it (so we can verify successful creation of the project + dependencies are downloaded).
    grails create-app bookstore
    cd bookstrore
    grails run-app
  3. Download and install the plugin
    grails install-plugin /path/to/plugin/grails-vaadin-1.5.5.zip
  4. Run the application
    grails run-app