Vaadin

Join Vaadin Log In

Grails plugin

Tags: grails groovy

There is a Grails plugin available that allows Vaadin applications to be run on Grails. See the plugin page for more details. You can also report bugs and add feature requests at the plugin's JIRA page at Codehaus.



Hello World with Vaadin on Grails

This is a simple example to help get you started with the Vaadin Grails plugin.

grails create-app hello-vaadin
cd hello-vaadin
grails install-plugin vaadin

  • To ensure that the requests to our application get through to your Vaadin app, you'll need to remove the URL mapping for the root context from your URL-mapping file. To do that, just remove the following line from hello-vaadin/grails-app/conf/UrlMappings.groovy
"/"(view:"/index") 

  • Next, create your implementation of com.vaadin.Application, as you would in your normal Vaadin applicaiton (this example is in Groovy, but Java works fine here too).
package com.mycompany

import com.vaadin.*
import com.vaadin.ui.*

class HelloVaadinApplication extends Application {

    void init(){
        def window = new Window("Hello Vaadin!")
        setMainWindow window
        def button = new Button("Click Meee")
        window.addComponent button
    }

}

  • Then point the Vaadin configuration file (hello-vaadin/grails-app/conf/VaadinConfig.groovy) at this new application class, like this:
vaadin {
    productionMode = false
    applicationClass = "com.mycompany.HelloVaadinApplication"
}

  • Now you're ready to run! Execute the following Grails command to start your application.
grails run-app

Then browse to http://localhost:8080/hello-vaadin to see it running!

0 Attachments 0 Attachments
4058 Views

Average (2 Votes)