Removing all items from a TreeTable

Hi everyone.

I am experiencing problems with clearing the contenst of a table. I tried everything described in
this
and
this
thread but I am unable to clear the table.

There is some discussion about this issue in this
ticket
. And according this ticket this issue was resolved in Vaadin 6.7.1. And infact when I reverted back to this version the code that I used to clear the contents of a table is working in this version. My issue is exactlly as descibed in this ticket. So when I remove all items from a table the table itself is not refreshed at all. I can see that my items are still there. But after I hit a browser refresh button than the table is empty.

I use Vaadin 6.8.6 so maybe this is a regression. So my question, is this a bug or the things have changed from 6.7.1 concerning removing all items and am I doing something wrong?

I know you guys need a minimal application that reproduces this issue so I will be back with this a little later, sorry. In short, I am using TreeTable with custom data source container. This custom container extends the
com.vaadin.data.util.BeanItemContainer
and implements
com.vaadin.data.Container.Hierarchical
interface. Don’t know why I didn’t used only
com.vaadin.data.util.HierarchicalContainer
. Anyway, when I want to remove all items from a table I just call
removeAllItems()
on TreeTable. I overriden this method in my custom container which sets up a new empty
List
of items that I need to put into table. After that I just call
super.removeAllItems()
.

Again, sorry for describing a code instead of puting one here. I am kind of feeling laizy today.

Since this is my first post and kind of negative one, just wanted to tell you guys that you made a wonderfull job with Vaadin. Can’t wait for the 7.0 release!


EDIT 1
: I managed to write a few lines of code to show you how can you reproduce this issue. To be correct, I just copied the “TreeTable, basic” example from Vaadin Sampler and added a button which will call
removeAllItems()
on TreeTable. Like I said, if you try bellow code with Vaadin 6.7.1 and if you click on this button, the items are gone and the table is empty. But if you try the same thing but with Vaadin 6.8.6 the table is not empty, that is - it still contains those items but if you click web browser refresh button than the table is magically empty.

package com.example.testtreetable;

import java.util.Calendar;
import java.util.Date;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

public class TesttreetableApplication extends Application {	
	protected static final String NAME_PROPERTY = "Name";
    protected static final String HOURS_PROPERTY = "Hours done";
    protected static final String MODIFIED_PROPERTY = "Last Modified";
    
    protected TreeTable treetable;
	
	@Override
	public void init() {
		Window mainWindow = new Window("Testtreetable Application");
		
		Button button = new Button("Clear");
		button.addListener(new ClickListener() {
			private static final long serialVersionUID = 1L;

			@Override
			public void buttonClick(ClickEvent event) {
				treetable.removeAllItems();
			}
		});
		
		mainWindow.addComponent(button);
		
		// Calendar
        Calendar cal = Calendar.getInstance();
        cal.set(2011, 10, 30, 14, 40, 26);
		
		// Create the treetable
        treetable = new TreeTable();
        treetable.setWidth("100%");

        mainWindow.addComponent(treetable);

        // Add Table columns
        treetable.addContainerProperty(NAME_PROPERTY, String.class, "");
        treetable.addContainerProperty(HOURS_PROPERTY, Integer.class, 0);
        treetable.addContainerProperty(MODIFIED_PROPERTY, Date.class,
                cal.getTime());

        // Populate table
        Object allProjects = treetable.addItem(new Object[] { "All Projects",
                18, cal.getTime() }, null);
        Object year2010 = treetable.addItem(
                new Object[] { "Year 2010", 18, cal.getTime() }, null);
        Object customerProject1 = treetable.addItem(new Object[] {
                "Customer Project 1", 13, cal.getTime() }, null);
        Object customerProject1Implementation = treetable.addItem(new Object[] {
                "Implementation", 5, cal.getTime() }, null);
        Object customerProject1Planning = treetable.addItem(new Object[] {
                "Planning", 2, cal.getTime() }, null);
        Object customerProject1Prototype = treetable.addItem(new Object[] {
                "Prototype", 5, cal.getTime() }, null);
        Object customerProject2 = treetable.addItem(new Object[] {
                "Customer Project 2", 5, cal.getTime() }, null);
        Object customerProject2Planning = treetable.addItem(new Object[] {
                "Planning", 5, cal.getTime() }, null);

        // Set hierarchy
        treetable.setParent(year2010, allProjects);
        treetable.setParent(customerProject1, year2010);
        treetable.setParent(customerProject1Implementation, customerProject1);
        treetable.setParent(customerProject1Planning, customerProject1);
        treetable.setParent(customerProject1Prototype, customerProject1);
        treetable.setParent(customerProject2, year2010);
        treetable.setParent(customerProject2Planning, customerProject2);

        // Disallow children from leaves
        treetable.setChildrenAllowed(customerProject1Implementation, false);
        treetable.setChildrenAllowed(customerProject1Planning, false);
        treetable.setChildrenAllowed(customerProject1Prototype, false);
        treetable.setChildrenAllowed(customerProject2Planning, false);

        // Expand all
        treetable.setCollapsed(allProjects, false);
        treetable.setCollapsed(year2010, false);
        treetable.setCollapsed(customerProject1, false);
        treetable.setCollapsed(customerProject2, false);
		
		setMainWindow(mainWindow);
	}
}


EDIT 2
: I tried to pinpoint the exact version where this issue is introduced after 6.7.1. And I concluded that the version 6.8.6 of Vaadin is to be blamed. Now I am definitivly sure that this is a bug. So, do you guys agree that I reopen a
ticket
?

Hi,

I checked out your example and yes, this is definitely a bug. Quick debugging shows that the container is properly emptied on the server side and the update is communicated to the browser but the client-side component is not updated.

Can’t say if it’s the exact same issue as a regression, but please do reopen the ticket and attach your example as a test case.

-tepi