TabSheet and components with scrollbar


I noticed a difference of behavior between vaadin 6 and vaadin 7.
When a TabSheet contains components with a scrollbar, the position of the scrollbar is not conserved when we change of tab. Each time I com back to a tab, the scrollbar of the component inside this tab is back to the top…

It was working well under vaadin 6 :frowning:
How can I solve this problem ?


Or which methods I must extend on a scrollable component to keep the scroll position ?

I tryed to send the scroll position from the onDetach function but the rpc seems to be already close because the server don’t receive anything ???

I need help please :frowning:

I finally chose to create my “own” TabSheet component.
My POC if it can help somebody :

package org.vaadin.aceeditordemo;

import java.util.HashMap;
import java.util.Map;

import com.vaadin.server.Resource;
import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TabSheet.CloseHandler;
import com.vaadin.ui.TabSheet.Tab;
import com.vaadin.ui.TextField;
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
import com.vaadin.ui.CssLayout;

public class MyTabSheet extends CssLayout {

    private static final long serialVersionUID = -2606375950491980753L;

    private static final String DISPLAY_NONE_CLASS_NAME = "displayNone";

    private TabSheet tabSheet = new TabSheet();
    private Map<Integer, Component> hashToComponentMap = new HashMap<>();
    private Component currentTab;

     * @see TabSheet#TabSheet()
    public MyTabSheet() {

     * @see TabSheet#TabSheet(Component...)
    public MyTabSheet(Component... components) {

     * @see TabSheet#addTab(Component, String)
    public Tab addTab(Component c, String caption) {
        return addTab(c, caption, null);

     * @see TabSheet#addTab(Component, String, Resource)
    public Tab addTab(Component c, String caption, Resource icon) {
        return addTab(c, caption, icon, tabSheet.getComponentCount());

     * @see TabSheet#addTab(Component, String, Resource, int)
    public Tab addTab(Component tabComponent, String caption, Resource icon,
            int position) {
        int hash = tabComponent.hashCode();
        hashToComponentMap.put(hash, tabComponent);

        // add a Component with the reference (hash) of the real component to
        // display. This component will never be displayed
        TextField t = new TextField("" + hash);

        // add all components with "display: none", the
        // SelectedTabChangeListener will display the tab to display

        return tabSheet.addTab(t, caption, icon, position);

    private void addListeners() {
        tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {

            private static final long serialVersionUID = 3262360390619159986L;

            public void selectedTabChange(SelectedTabChangeEvent event) {
                int hash = Integer.valueOf(tabSheet.getSelectedTab().getCaption());
                Component selectedTab = hashToComponentMap.get(hash);

                if (currentTab != null)
                currentTab = selectedTab;
        tabSheet.setCloseHandler(new CloseHandler() {
            private static final long serialVersionUID = -3607403614494881456L;

            public void onTabClose(TabSheet tabsheet, Component tabContent) {
                int hash = Integer.valueOf(tabContent.getCaption());
                Component c = hashToComponentMap.remove(hash);
                if (c != null)