I want to create panel object (working as a kind of navigation bar) shared between pages. I want to add buttons dynamically, so it’s important to me that all pages share the same object.
However when I add the panel to second page it disappears from the first one! Why is it so?
And maybe any tips how to deal with it? 🙂
The Vaadin component hierarchy allows for one component to be at one place at a time. In other words, you can’t have the same Component instance added to two places at the same time.
The best solution would be to move your panel so that the panel is never replaced, only the surroundings. If that’s impossible, you need to just recreate the controls for each page.
If your controls are stateful, remember that Properties can be shared between Fields, and all classes extending AbstractFields are Properties, so you can do stuff like
This way your two textfields are backed up by the same Property. So, after the value has changed, your two textfields have the same value.