Jhon
Jhon

Reputation: 87

Using layouts from others classes in vaadin

Is there any idea wich allows me using layouts declared in MyApplication.java from other classes and functions. I tried put them in parameters it works but it becomes very complicated For example xhen callin a function named Y in function X I have to pass all layouts on parameters like this:

X(layout1,layout2,layout3,layout4) { Y(a,b,c,layout1,layout2,layout3,layout4) }

I tried to use a class named uiHelper but it didn't works

Upvotes: 0

Views: 189

Answers (1)

Linh Nguyen
Linh Nguyen

Reputation: 659

You can take a look at Blackboard addon for vaadin.

https://vaadin.com/addon/blackboard

From that page:

Sometimes, having a deep component hierarchy poses a problem, when you need to inform a component high up in the tree that something happened deep down below. You normally have one of two choices - either pass the listener all the way down the hierarchy, leading to more coupled code, or let each component in between be a listener/notifier, passing the event all the way back up. With the Blackboard, you can register any listener to listen for any event, and when that event is fired, all the listeners for that event are triggered. This keeps your components clean and rid of unnecessary boilerplate code.

For your example, you can create a LayoutChangeListener and LayoutChangeEvent. MyApplication can then implements LayoutChangeListener and when a LayoutChangeEvent is fired, you can change your layout without passing it around.

Upvotes: 1

Related Questions