Client side component, inside tab disappears

I’ve written a client side componet which I have placed inside a Tab.

The client side compoents works as expected, except that when I change tabs and come back to the tab containing my client side compoent it is no longer present.

I believe that the TabSheet is removing my compoent from the DOM when the selected Tab changes, and then recreating it from scratch and expecting my compoent to rebuild itself from the shared state in the OnStateChange method. Is this correct?

If this is correct how can I avoid this?

I need to avoid this because there is no way for my client side component to recreate it’s state as it displays 3rd party html and invokes 3rd party javascript which it and users interact with.


Do you resolve the issue?

I have the same problem…

I worked around it by creating a replacement Tab component that doesn’t destroy the client when the tab is changed. see below…

import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.VerticalLayout;

 * unfortunately when a Component is hidden vaadin removes it from the browser
 * completely causing it to loose any non vaadin state... vaadin tabs take this
 * one step further by actively causing the removal of the component from the
 * browser when the tab is not selected.
 * As this is a problem for our component (it has state which can not be
 * persisted in vaadin), this "VirtualTabs" was created
 * which works by changing the size of the various tabs to 0 when not selected
 * The public methods which are implemented conform to the Vaadin TabSheet
 * method signatures
 * @author rsutton
public class VirtualTabs extends VerticalLayout
    private static final long serialVersionUID = 1L;
    // Logger logger = LogManager.getLogger();
    CssLayout buttons;
    Component currentComponent = null;

        setMargin(new MarginInfo(true, false, false, false));
        buttons = new CssLayout();


    public void addTab(final Component htmlContainer, final String caption)
        Button tabButton = new Button(caption);
         tabButton.addClickListener(new ClickListener()

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event)

                setExpandRatio(currentComponent, 0);

                currentComponent = htmlContainer;
                setExpandRatio(currentComponent, 10000);

        if (currentComponent == null)
            currentComponent = htmlContainer;
            setExpandRatio(htmlContainer, 10000);



    public Component getSelectedTab()
        return currentComponent;