Making Vaadin, PureMVC and Grails Work Together

On seeing that someone had developed a Grails Plugin for Vaadin (the former ITMill Toolkit, based on GWT as a front end technology), I immediately grabbed it and started exploring. One of the first things I do when developing things that look like GUI's is apply PureMVC to it. It's sort of like a big MVC switchboard that lets you hook together the smaller MVC's of whatever framework you're using. Overkill for really simple applications. Crucial for big ones.

Building a PureMVC app was pretty quick, but I ran into a small problem. Since PureMVC Multicore uses a Multiton pattern (essentially a map of Singletons), when Grails recompiles and restarts on code changes, the application barfs with a "Facade already constructed" runtime error. The solution is simple. In your subclassed org.puremvc.java.multicore.patterns.facade.Facade, change the following:

  public static ApplicationFacade getInstance() {
    if (instance == null) {
      instance = new ApplicationFacade(CORE)
    }
    return instance
  }

to this:

  public static ApplicationFacade getInstance() {
    if (instance == null) {
      // nuke the multiton so we can do the grails recompile
      if (ApplicationFacade.hasCore(CORE)) {
        ApplicationFacade.removeCore(CORE)
      }
      instance = new ApplicationFacade(CORE)
    }
    return instance
  }

And voila, your app now recompiles and runs without a hitch, just like a Grails app should. (CORE is a string constant to name your core.)

Related Services: Java Application Development, Custom Software Development

Related posts:

  1. A Slight Correction to using PureMVC with Vaadin
  2. Making GWT JSON not Quite so Painful
  3. Notification Testing with PureMVC and FlexUnit
  4. Grails: Delegating to GORM Persistence in Java
  5. Getting CloudTools to Work with Grails 1.1.1

Comments: 4 so far

  1. Hi Dietrich, I’m really glad to see that you’ve used the plugin. What did you think of it? Any suggestions?
    Regards,
    Daniel

    Comment by Daniel Bell, Friday, August 28, 2009 @ 4:43 am

  2. Hi Dietrich and Daniel,

    I’m considering using Grails and Vaadin for a new app I am developing. Can you provide any info on how to best perform data binding between Vaadin data model “items” and Grails domain objects?

    Or do you use Grails services?

    Many thanks,

    – Rodney

    Comment by Rodney Schneider, Tuesday, September 22, 2009 @ 1:22 am

  3. Hi Dietrich

    Nice article.

    I am learning Vaadin now and am interested in seeing how you integrated PureMVC. Do you have source code available?

    Thanks in advance

    Barton

    Comment by Barton Hammond, Sunday, October 4, 2009 @ 2:26 pm

  4. [...] while back I looked at the Vaadin Plugin and tried to make it work with the Multiton PureMVC. Back then I proposed the [...]

    Pingback by | Pathfinder Development | Software Developers | Blogs, Monday, February 1, 2010 @ 2:36 pm

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com