Home > Blockchain >  Accessing layout from inside Vaadin 23 view
Accessing layout from inside Vaadin 23 view

Time:05-16

I'm using Vaadin 23.

I defined a "MainLayout" class to carry the drawer among other things.

In my view declaration, i have the annotation :

@Route(value = "", layout = MainLayout.class)

In the view, if I try

this.getParent();

the returned optional is empty.

So, how can I call a method in my MainLayout class from my view instance ?

CodePudding user response:

Instead of creating strong coupling between your views and main layout, you can use the Eventbus with custom events thrown by your view and your layout listening on them.

You can find a official example in the cookbook of Vaadin https://cookbook.vaadin.com/ui-eventbus

CodePudding user response:

I'd try with:

UI.getCurrent().getChildren()
  • Related