Table entry selection disappears

I have a Table that’s populated with a HbnContainer object. When I set a search parameter on the HbnContainer, some of the Table entries will (probably) disappear. This works fine, and the Table updates to the new state automatically.

However, below the table, I have a panel that shows some information about the selected entry from the Table. This is not updated. And when I call getValue(), the returned object is still the one from the previous set. It seems the table doesn’t clear the seleted object when the table data is changed.

Is this a Vaadin bug, or have I forgotten something?

Bo Thorsen.
Monty Program AB.

In the place where I add the select to the HbnContainer, I also added this code:

		if (entryList.getValue() != null) {
			if (!entryList.getVisibleItemIds().contains(entryList.getValue())) {
				entryList.setValue(null);
			}
		}

That removes the currently selected item.

But I would have expected the table to do this automatically.

Bo.

The problem seems to be that when you apply a filter on the container the container’s items are reduced as expected. The Table will notice this change in the container and update its content. What it however does not do, is check if the currently selected value is within the filtered container’s results. This means that it won’t notice that the value is no longer valid and it will NOT set the value to null, as one would expect. Since it does not set the value to null, neither will a ValueChangeEvent be sent and hence your Label will not be updated.

I have to agree with you that one would expect the table to set its value to null if the previous value is no longer within the container’s items. I’ve filed a ticket (
#3566
) about this matter. For now, the only way to solve the problem is to check yourself if the table’s value is valid after the filter has been applied.