In the Vaadin framework (v7.1.9), how do we remove a Component
from it's parent?
I'm only aware of the removeComponent
function, but that requires me to get a handle on the parent (ugly):
ComponentContainer parent = (ComponentContainer) child.getParent();
parent.removeComponent(child);
I tried to just detach
the child but that removed it from the 'application' without removing the Component
from the UI.
if Child is added to Any Layout you should cast it to that layout e.g if child ws added to AbsoluteLayout then
AbsoluteLayout parent = (AbsoluteLayout ) child.getParent();
parent.removeComponent(child);
Try this one
Or like this if child was added to layout.
Layout parent = ( Layout ) child.getParent();
parent.removeComponent(child)
I think this is better than Mubasher solution because it's implementation independent, I mean you don't have to know the Parent layout and if it changes the code still works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With