BenjaminD
BenjaminD

Reputation: 554

Accessing layout from inside Vaadin 23 view

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 ?

Upvotes: 1

Views: 858

Answers (2)

Knoobie
Knoobie

Reputation: 2064

UI event bus

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, Communicate between components attached to one UI.

Upvotes: 5

Kruntz
Kruntz

Reputation: 13

I'd try with:

UI.getCurrent().getChildren()

Upvotes: 0

Related Questions