Directory

← Back

MVP for Flow

Helper addon to use the MVP pattern on Vaadin flow

Author

Rating

Popularity

<100

An addon that provides a predefined class structure to make the development of UIs using the Model-View-Presenter Pattern more comfortable under Vaadin flow.

View

public class TestView extends VerticalLayout {
    private final Button button1;
    private final Button button2;
    private final Button button3;
    private final Button button4;

    public TestView() {
        button1 = new Button();
        button2 = new Button();
        button3 = new Button();
        button4 = new Button();
        add(button1, button2, button3, button4);
    }
    //... getters and setters
}

Presenter

@Route("")
public class TestPresenter extends Presenter<TestModel, TestView> {

    public TestPresenter() {
        String[] descriptions = getModel().getDescriptions();
        getContent().getButton1().setText(descriptions[0]);
        getContent().getButton2().setText(descriptions[1]);
        getContent().getButton3().setText(descriptions[2]);
        getContent().getButton4().setText(descriptions[3]);
    }
}

Model

public class TestModel implements Model<TestModel> {
    public String[] getDescriptions() {
        return new String[]{"Button1", "Button2", "Button3", "Button4"};
    }
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Released
2019-10-21
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 10+
Browser
Browser Independent

MVP for Flow - Vaadin Add-on Directory

Helper addon to use the MVP pattern on Vaadin flow MVP for Flow - Vaadin Add-on Directory
An addon that provides a predefined class structure to make the development of UIs using the Model-View-Presenter Pattern more comfortable under Vaadin flow. ### View ``` public class TestView extends VerticalLayout { private final Button button1; private final Button button2; private final Button button3; private final Button button4; public TestView() { button1 = new Button(); button2 = new Button(); button3 = new Button(); button4 = new Button(); add(button1, button2, button3, button4); } //... getters and setters } ``` ### Presenter ``` @Route("") public class TestPresenter extends Presenter { public TestPresenter() { String[] descriptions = getModel().getDescriptions(); getContent().getButton1().setText(descriptions[0]); getContent().getButton2().setText(descriptions[1]); getContent().getButton3().setText(descriptions[2]); getContent().getButton4().setText(descriptions[3]); } } ``` ### Model ``` public class TestModel implements Model { public String[] getDescriptions() { return new String[]{"Button1", "Button2", "Button3", "Button4"}; } } ```
View on GitHub
Issue tracker

MVP for Flow version 1.0.0

Online