Vaadin Grails Plugin

Hi All,

Based on Daniel’s work, I’ve released a new (version 1.1) Grails Vaadin plugin. It now supports:

  1. Latest stable Vaadin version (6.3.3 at this time)
  2. Paths to your Vaadin UI other than the context root (e.g. http://www.somehost.com/myapp/vaadinUI)
  3. Per-environment configuration (Vaadin’s ‘production mode’ = true for Grails production environment only. Can be overridden for any environment). Custom environments are also supported (e.g. ‘beta’, ‘uat’, etc)

A huge benefit to Grails 1.3 users is that because Grails 1.3 supports Groovy 1.7, which can use nested and anonymous inner classes, you can program all of your Vaadin UI in Groovy with natural Rich UI paradigms. For example, button listener registration and nested logic:

// Remove a contact from a list:
def removalCount = 0
contactRemovalButton = new Button("-", new Button.ClickListener() {
   void buttonClick(ClickEvent event) {
       contactList.removeItem(contactList.value)
       //reference a non-final attribute inside an anonymous inner class!
       removalCount++;
    }
})

To install in your grails app:

grails install-plugin vaadin

Happy coding!

Les Hazlewood

http://www.katasoft.com

HI,

I tried this plugin. I have a simple objective that I can be productive by writing my Vaadin code in groovy hence avoiding any restarts/redeploys. In theory I would like to have only the changed class reloaded. Just like how JVM hotswap works. But what I observed is that any changes to files in src/groovy trigger a complete container restart which is not the desired result. I would love it it works like Jrebel (zeroturnaround.com) which replaces only the changed artifacts. My groovy scripts are places in src/groovy. Am I doing anything wrong?
Thanks.

HI

I have the same behaviour. It’s normal, cause to enable single class reloading in grails (like controllers or services) you need to write special artifact handling plugins.
As for me, this restart is very fast, so it doesn’t harm development a lot

Another issue in grails: when you are using services in vaadin app. you need to restart application (?restartApplication) after service change (cause grails reloads changed service, but it can’t update working vaadin apps)

In summury I can say that I feel very comfortable with vaadin in grails

Hi All!

Who can upgrade plugin to vaadin 6.4.6?

Thanks!

I am running the SimpleAddressBook Vaadin tutorial using a Grails application and the Grails Vaadin plugin. I have created a groovy file (SimpleAddressBook.groovy) containing the tutorial sample code with small modifications to the array initializers. There is a problem with filtering the table using the bottom column filters: it always returns 0 matches (no matter what value I use for the filter string). However if I rename SimpleAddressBook.
groovy
to SimpleAddressBook.
java
the filtering works fine.

Any ideas why is this happening?

I’ve changed VaadinGrailsPlugin.groovy like below and it works.


        def vaadinApplicationClass = config.applicationClass
        def vaadinProductionMode = config.productionMode
        def vaadinGAEMode = config.googleAppEngineMode
        def applicationServlet = vaadinGAEMode ? GAE_APPLICATION_SERVLET : APPLICATION_SERVLET

        def contextParams = webXml."context-param"
        contextParams[contextParams.size() - 1]
 + {
            "context-param" {
                "description"("Vaadin production mode")
                "param-name"("productionMode")
                "param-value"(vaadinProductionMode)
            }
        }

        def servletName = "VaadinServlet"

        def servlets = webXml."servlet"
        servlets[servlets.size() - 1]
 + {
            "servlet" {
                "servlet-name"(servletName)
                "servlet-class"(applicationServlet)
                "init-param" {
                    "description"("Vaadin application class to start")
                    "param-name"("application")
                    "param-value"(vaadinApplicationClass)
                }
                "load-on-startup"("1")
            }
        }

        def contextRelativePath = config.contextRelativePath ? config.contextRelativePath : "/";
        if (!contextRelativePath.endsWith("deneme/")) {
            contextRelativePath += "deneme/";
        }
        def servletMapping = contextRelativePath + "*"
        def servletMappings = webXml."servlet-mapping"
        servletMappings[servletMappings.size() - 1]
 + {
            "servlet-mapping" {
                "servlet-name"(servletName)
                "url-pattern"("/deneme")
            }
        }
        if (!contextRelativePath.equals("/")) {
            //need to additionally specify the /VAADIN/* mapping (required by Vaadin):
            servletMappings[servletMappings.size() - 1]
 + {
                "servlet-mapping" {
                    "servlet-name"(servletName)
                    "url-pattern"("/main/*")
                }
                "servlet-mapping" {
                    "servlet-name"(servletName)
                    "url-pattern"("/VAADIN/*")
                }
            }
        }
    }

11518.html (11.5 KB)

The Vaadin Grails plugin works great. The only serious limitation that I see is that it limits you to a single Vaadin app. Any serious web site will have multiple Vaadin apps targeting specific areas. For example, the travel agent might have an app managing all the trips available for customers and then another app is used by the customer to manage their specific trips.

Am I missing how to configure this with Vaadin.groovy config file?

If this is not possible, are there any plans to support this? I love Grails and Vaadin, but this is a serious limitation that I cannot live with unfortunately.

Thanks in advance,
Frik

I know next to nothing about Grails, but as far as I understand it there should be no limitations from the Vaadin side. The Grails plugin is a community effort (the official roadmap is
here
), so patches are more than welcome :slight_smile:

Agree - this is definitely not a Vaadin limitation. This is a limitation of the Vaadin plugin for grails.

If no one else has done the work already, I will definitely consider updating the plugin to support this.

Thanks for your response.

Kind regards,
Frik

Can everyone please vote to show how important it is to support multiple Vaadin applications on a single Grails server?
http://jira.codehaus.org/browse/GRAILSPLUGINS-1894

This is an old post, but didn’t see an answer on here regarding this problem. I recently ran into this myself, and though, cause is unknown (something between Vaadin, Grails, and Hibernate - helpful, huh?), I was able to get around this by only showing relevant data fields in the container I was populating and ignoring those put in by GORM/Vaadin using setVisibleColumns().

Seems simple enough. Like I said, exact cause unknown, but this works in my case. Freakishly, this problem led me to start developing my Grails view layer in Zk (gasp!), but now I’m back to Vaadin and very, very relieved.

Chris

I need an answer to this problem too. I have many classes that have associations to other classes.

e.g.

Person has a Company.

I want to be able to display the Person instances with the name of the company in a Table. In other frameworks, I can use “dot notation”. e.g. firstName, lastName, company.name, company.ticker, etc…

Furthermore the Company may have an Address. Therefore, I would want to display company.address.city, company.address.state, etc…

I may want to display this in a Table or a Form.

I cannot use “eager” loading. What can I do today to get lazy loading to work?

JPA specification does not support lazy loading for detached entities, and Hibernate does not support it by design - EclipseLink does to some extent. This is further complicated by the fact that the only way to re-attach an entity to a session is to merge() it (or reload it from scratch based on the id etc).

When using the JPA-session-per-request pattern (as usual in web applications), in the next request from the UI your entities are not anymore attached to the old session, so lazy loading for them does not work. As you usually keep the restored entity instances in the application (in e.g. a Tomcat session), they are no longer valid for lazy loading upon the next request when using Hibernate.

Some frameworks - especially Web 1.0 style applications - can work with this because they never hold onto entity instances in memory but always reload them on every request. However, any system that does not do so will have problems with lazy loading when using Hibernate.

This is further complicated by the Hibernate “feature” that the session is invalidated when there is an exception, so using sessions that span many HTTP requests is not really an option either with Hibernate.

To summarize, I believe your options are to:

  • disable lazy loading selectively or
  • arrange for the entities/values to be re-loaded in each request (e.g. by not storing entity instances but only IDs) - how to do this and whether it is really doable depends on the application or
  • check whether e.g. EclipseLink works better than Hibernate in your case

Suggestions for better alternatives would be welcome.

Hey Daniel,

Have you guys with Les considered adding scaffolding to the Vaadin Grails plugin?
I mean, is it on roadmap already?

I’m asking because I’m interested in contributing to the plugin in such way but don’t want to duplicate the feature.

Speaking about contribution. Is there any specific condition to become commiter?

Regards,
topr

Commit question might be of general interest. Split the thread. The new thread can be found at
http://vaadin.com/forum/-/message_boards/view_message/454319
.

The Jira ticket that I raised originally to add support for multiple Vaadin applications using the Grails plugin has moved to:
http://jira.grails.org/browse/GPVAADIN-2

As one can see that was raised about a year and a half ago, so I don’t think that anyone has had a chance to look at it yet. I think the best way would be if we simply got commit rights or at least provided a patch that could be incorporated in the next release of the plugin.

On that note, does anyone know what the roadmap is for the plugin, if there is one?

Regards,
Fredrik

Hi Krish, have you found any solution for this problem?

Regards

[quote=krishvaadin kri krish]
Server running. Browse to http://localhost:8090/hello-vaadin
[groovyc]
Compiling 1 source file to
C:\Java\test\GrailsTests\hello-vaadin\target\classes
[groovyc]
Compiling 2 source files to
C:\Java\test\GrailsTests\hello-vaadin\target\classes
[delete]
Deleting directory C:\Documents and
Settings\admin.grails\1.2.1\projects\hello-vaadin\tomcat
2. When I load the page in browser, the page is sometimes unavailable
(error 503).
Maybe this has something to do with the first problem.
Has anyone seen the same problem?

Is the Grails Vaadin plugin still maintained?

If so, or even if not, where is the source repository located so that others might fork it?

Thanks

Hi Kirk,

here is the JIRA project for this plugin: http://jira.grails.org/browse/GPVAADIN It seems there are only new requests but not that much of done work… :-/ I have asked to upgrade the plugin to the latest version of Vaadin (but I am not sure if that is going to happen).

I am trying to develop some CRUDS with Vaadin grails plugin but i am having some problems.
Is there any tutorial? working sample?
I am having problems with data on demand because i have some tables with more than 500K records and when i use

Person.list().each { container.addBean it }

to populate the container, the entire application collapse…

can someone give me a hand with that?

thanks!