Friday, July 5, 2013

Using a Publish-Subscribe messaging pattern in Vaadin

The events system described by the Book of Vaadin is quite primitive. It's a standard Observer pattern (aka Listener pattern). 

Unfortunately, since the Listener requires access to the source object, this makes it highly coupled (the listener has to know about the source). 

What's worse is, in a practical sense, since Vaadin events do not "bubble" (not on the server side at least), its very difficult "get the handler to the required component" without violating all kinds of information hiding best practices.

What we really want is a publish-subscribe architecture that is similar to Parsley's in Flex.

GWT does provide a SimpleEventBus. And Vaadin does include this. And blogger Alex Tretyakov has here a great example of how to use it. As of this writing, its the best example out there.

Wednesday, July 3, 2013

Creating a Vaadin application using M2Eclipse (aka m2e) gives an error

I use M2Eclipse (and m2e-wtp) to create a vaadin-archetype-application. It works, but M2E keeps complaining about the below error.

"Plugin execution not covered by lifecycle configuration: com.vaadin:vaadin-maven-plugin:7.1.0:update-theme (execution: default, phase: generate-sources) "

Yes its a harmless error. But its irritating for an OCD like me. This is (probably) because m2e doesn't know about some of Vaadin's Maven goals:

  1. compile-theme
  2. update-theme
The way I solve let m2e know about it is:
  1. search the pom.xml for m2e's lifecycle config. Do a search for "org.eclipse.m2e".
  2. m2e will have tried to put some goals into vaadin-maven-plugin's plugin execution. e.g. <goal>resources</goal>
  3. put in the missing <goal>compile-theme</goal> and <goal>update-theme</goal>.
  4. update the Eclipse's Maven config. The easiest way is to quick fix ⌘1.