Vaadin 7 on Grails 2.x
  • Introduction
  • Project setup
    • Command Line
    • IntelliJ IDEA
    • Eclipse
    • NetBeans
    • Plugin Configuration
    • Clean up
    • Best Practices
  • Database
    • GORM
      • Create Domain Model
      • Transactions
      • LazyInitializationException
      • Open Session In View I.
      • Open Session In View II.
      • Table Container
    • Groovy SQL
      • Create Sql
      • Execute SQLs
    • MyBatis
      • Configuration
      • Basics
    • JdbcTemplate
      • Create Beans
      • Usage
    • Clean Up With Alternatives
  • Architecture
    • Model View Presenter
  • Spring Autowiring
    • Create Simple Application
    • Application With Navigator
  • UI
    • Re-using GORM Validations
    • Async Push
    • Multiple application
    • SASS Compilation
    • Widgetset Compilation
  • Spring Security
    • Spring Security Dependency
    • Spring Security Basics
    • Secured Navigator
  • Localization
    • Localization Basics
    • Custom MessageSource
  • REST
    • Without using root URL
    • Using root URL for Vaadin app
  • Plugin development
    • Github
    • Development
Powered by GitBook
On this page
  • MyUI.groovy
  • VaadinConfig.groovy
  • mapping
  • mappingExtras
  • productionMode
  • asyncSupported
  • themes
  • sassCompile
  • widgetset
  • servletClass
  • packages
  • uiProvider
  • openSessionInViewFilter

Was this helpful?

  1. Project setup

Plugin Configuration

PreviousNetBeansNextClean up

Last updated 5 years ago

Was this helpful?

When we add dependency to into BuildConfig.groovy and run grails compile the plugin generates the following files inside our Grails application.

MyUI.groovy

Sample UI class src/groovy/app/MyUI.groovy which contains code that just shows a label in the web browser.

We can immediatelly start coding Vaadin application using that file, or maybe rather do a refactoring. For example, rename the file to AppUI.groovy and move it to different package (folder) src/groovy/com/company/app. Then you need to change mapping property inside VaadinConfig.groovy.

VaadinConfig.groovy

Vaadin configuration file grails-app/conf/VaadinConfig.groovy contains all the configuration that is required by the plugin.

We will explore what all can be configured in VaadinConfig.groovy.

mapping

We can provide multiple Vaadin UI classes that extends com.vaadin.ui.UI and they will be mapped to specified URL patterns. There must be at least one UI class.

Let's look at this example where we map three URL paters, each to separate UI class.

    mapping = [
        "/*": "app.MyUI",
        "/admin/*": "app.AdminUI",
        "/client/*": "app.ClientUI"
    ]

The application UIs will then become available at:

mappingExtras

We need to define extra mapping in case we need to 'reserve' a URL that should not be mapped to, for example, /* by Vaadin.

Then we provide mapping for /console/* pattern.

mappingExtras = [
    '/console/*'
]

productionMode

By default, the productionMode is set to false also inside Grails.

productionMode = false

In order to enable productionMode in production, make sure the following code is present.

environments {
    production {
        vaadin {
            productionMode = true
        }
    }
}

asyncSupported

asyncSupported = true

themes

themes = ['sample']

sassCompile

You can specify exact version of Vaadin for SASS compilation.

sassCompile = '7.6.1'

widgetset

In order to use your own widget set, for example, if you need to use add-ons.

widgetset = 'com.mycompany.widgetset'

If widgetset is not set, the default widget set from Vaadin is used.

servletClass

servletClass = "com.app.MyGrailsAwareApplicationServlet"

packages

We can define a package name where Spring will search for components.

packages = ['com.mycompany.vaadin']

This is optional, all packages will get scanned by default.

uiProvider

uiProvider = "com.mycompany.MyGrailsAwareUIProvider"

openSessionInViewFilter

In order to activate Open Session in View for Hibernate 3.

openSessionInViewFilter = 'org.springframework.orm.hibernate3.support.OpenSessionInViewFilter'

Or this for Hibernate 4.

openSessionInViewFilter = 'org.springframework.orm.hibernate4.support.OpenSessionInViewFilter'

Be aware, creating multiple UIs is not the way how to navigate in the Vaadin applicatin. Use for this.

For example, we need to enable plugin. First we add plugin dependency compile ":console:1.4.4" into BuildConfig.groovy.

To get console plugin working, you need to apply .

When is set to false, it enables debug mode. So, we can easily inspect application in browser by adding ?debug to the end of URL.

Set this property to true to enable asynchronous communication, so you can use .

You can provide name of the , which is a directory name in web-app/VAADIN/themes folder.

There is a default servlet, , provided by Vaadin plugin that makes actually possible to run Vaadin inside Grails.

If you need to create your own servlet, you can do it by extending . Then set servletClass to your custom servlet.

We can create own implementation of .

This is optional, default is .

Vaadin plugin
http://localhost:8080/grails-vaadin7-demo
http://localhost:8080/grails-vaadin7-demo/client
http://localhost:8080/grails-vaadin7-demo/admin
views navigator
console
this hack
production mode
Vaadin push
themes
com.vaadin.grails.server.DefaultServlet
com.vaadin.grails.server.DefaultServlet
com.vaadin.server.UIProvider
com.vaadin.grails.server.DefaultUIProvider