How To clear TreeTable items

Hi,

I am using using Vaadin 6.7.0 for my web application.
I found out that TreeTable removeAllItems() method does not work.

I came across a forum which said that this bug has been fixed in version 6.7.1.
I cannot switch from Vaadin 6.7.0 to Vaadin 6.7.1 as this decision does not lie in my hand.

I tried to override the removeAllItems() within my TreeTable but it gives me a NullPointerException somewhere in the removeItem(Object) method.

Following is the code-

@Override
public boolean removeAllItems() {
for (Object itemId : getItemIds()) {
super.removeItem(itemId);
}
return true;
}

What can be the possible work-around which will let me clear the TreeTable?
Help is very much appreciated.
Thanks.

Hi,

I took a quick look at the ticket and the patch and as far as I can see, there’s no simple workaround. I guess the simplest way without updating the Vaadin version would be to just remove your TreeTable completely and create a new one (and replace the old one with it) whenever you need to remove all the items.

Another option is to create your own custom version of treetable with a corresponding client-side class that would then include the fix. This might be quite a bit more work, since the fixed code seems to be in a private method of VScrollTable class.

Hi Teppo,

Removing the TreeTable and replacing it with new one was the last thing on my mind.
But it seems thats the only potential solution now.
I tried it and it works fine. I had to re-create the TreeTable, replace old one with the new one and also had to set a new empty container to it.

Thanks for the help.
I did not have to spend time finding some other workaround. :slight_smile: