Vaadin and MVP Pattern

Hi folks,

i’m writing my first vaadin application and i looking for some best practices. I reader this article and want use mvp pattern for my application.

At the moment i cant understand how i can connect it with my
MainUI extends UI
where my application start.

There are other resources about mvp patterns in Vaadin?


The view implementation is a component.

public class MyUI extends UI {
    public void init(VaadinRequest request) {
        // Create the content root layout for the UI
        VerticalLayout content = new VerticalLayout();

        // Create the model and the Vaadin view implementation
        CalculatorModel    model = new CalculatorModel();
        CalculatorViewImpl view  = new CalculatorViewImpl();
        // The presenter binds the model and view together
        new CalculatorPresenter(model, view);
        // The view implementation is a Vaadin component

Note that the MVP pattern actually
really so commonly used in Vaadin applications, even though the article says so. Some projects use it extensively, but usually the two-way abstraction is just a distraction. It is useful
you have or expect to have more than one view implementations.

So, you should start from the
basic application architecture
, and unless you specifically need MVP, you could consider it.

Tnx Marko,

now i understand how use it. Maybe i will continue with the actual implementation. I’m using a lot the navigator for switch beteween sub-view and maybe the two-way abstraction is just too much atm. But it’s good to know mvp too :slight_smile: