Vaadin4Spring: Architecture patterns?

Hello everyone,

my team is using the latest version of Vaadin and Vaadin4Spring. We have it up and running, but we are struggling with the general architecture. In particular which classes are spring beans and which classes are not.

Here’s a small example of the pattern that we use all over our application:

We have editor components that extend a vaadin Layout (usually VerticalLayout) and edit a domain model element. The editor is the “View” in the Model-View-Controller pattern.

public class MyEditor extends VerticalLayout {
    private final MyPresenter presenter;

    public MyEditor(MyDomainObject objectToBeEdited){
         this.presenter = new MyPresenter(objectToBeEdited);

    public void createContents(){
         // create the vaadin UI here
         // for example: this.addComponent(new Label("Editor Title"));

… and this is the presenter (the “Controller” in the MVC pattern):

public class MyPresenter {
    private final MyDomainObject objectToBeEdited;

    public MyPresenter(MyDomainObject objectToBeEdited){
       this.objectToBeEdited = objectToBeEdited;

    public void performComplexOperation(){
        // does some complex stuff with 'objectToBeEdited'
        // this is called from an event handler on a button, for example

The problem is:

  • We do not want our “editor” classes to be spring beans.
  • Reason: editors can create sub-editors (recursively) and we don’t want to pass some “UI Factory” as argument every time that accesses the spring context and retrieves a new prototype instance.

  • We would like our “presenter” classes to be spring beans.
  • Reason: presenters should be able to auto-wire @Service layer beans

  • We don’t want ‘static’ (as in the java keyword) references, because they lead the entire Dependency Injection ad absurdum

How do you solve such problems in your applications? Just doing everything in a single @VaadinComponent just isn’t feasible for us (that’s the difference between a tutorial and the real world, I guess).

We’d be grateful for any advice.