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

In this 




