Question

I try to implement a site with Vaadin but i dont know if i understand the Vaadin UI and Views totally wrong. What i want to realize is to define a base template for my site and display different views inside my base template.

My first approach would be to define the base template inside an UI and the content inside different Views (loaded through the Navigator). Is this possible or did i get the concept of Vaadin UI and Views totally wrong? And if this is possible, how should i implement it correctly?

My first approach would be the following sample. But the views loaded with the Navigator replace the complete base template from the UI... what did i wrong?

public class MyUI extends UI {

    private Layout rootLayout;

    @Override
    protected void init(VaadinRequest request) {
        buildBaseTemplate();
        Navigator navigator = new Navigator(this, rootLayout);
    }

    private void buildBaseTemplate() {
        rootLayout = new CssLayout();
        /* ... my base template ... */
    }
}

public class MyFirstView implements View {

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
        buildView();
    }

    private void buildView() {
        /* ... my view definition ... */
    }
}
Was it helpful?

Solution

this is a proper approach. but the Navigator will replace the content of the rootLayout so maybe you are better off passing some layout, which is inside your rootLayout. If you have a more complex setup (e.g. show the login-view "fullscreen") you might need to write your own ViewDisplay implementation, that deals with this (pass by ctor of Navigator).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top