calling TreeGrid refreshItem() doesn't refresh and odd "not in the hierarch

I have the very odd and annoying effect that a call to
doesn’t update the visual as I would expect.

I have two views onto the same item (a tree and a form displaying data of individual nodes - very similar in fact to your Vaadin-CRM example from which I started except that I keep the form open after changing and saving the bean’s values). In order to update the left-hand side tree-view I trigger said refreshItem() call on that node after having updated the bean.

Trying to debug this I am by now logging the node’s state before calling refreshItem(node).
The bean’s values are absolutely correct, but the on-screen visuals are not updated accordingly by this call.

After collapsing the tree and expanding it again the correct values are shown, again proving that the change IS there, it’s just not updated/refreshed on-screen.

Any idea or hint what could cause this?

Furthermore, and maybe related, I lately (too) often run into this message while collapsing/expanding a subtree (I only noticed that since I kept repeatedly collapsing and expanding the tree due to the above update issue):

java.lang.IllegalArgumentException: Item 'IntermediateNode' not in the hierarchy
	at com.vaadin.flow.internal.StateTree.lambda$runExecutionsBeforeClientResponse$1(

On screen I then get an error box reading:

Please notify the administrator.
Take note of any unsaved data, and click here or press ESC to continue.

Clicking onto the link reloads the data and everything seems OK again, so I have no clue why or what causes Vaadin to consider that item as not being part of the hierarchy. I guess I ran into some bug?

Any ideas on that?

Hi, is it related to this issue?

It has been last week and will probably be in the next 14.4.x.

Unfortunately not. I checked and also tried with the fix suggested there, i.e.:

  grid.getDataProvider().refreshItem(root, true);

but this did not resolve the screen update issue.

Also, in my case, I am not removing any child here. The beans, the tree structure (i.e. all parent/child relationships) as well as the DataProvider remain the same during the entire timespan that I am discussing here. I am only changing attribute values of the beans (associated with the grid-nodes via a DataProvider) and I am only trying to get the display to update after some values have changed.

Any other ideas?
Could it have to do that the change is done by an asynchronous task which then calls

component.getUI().ifPresentOrElse((ui) -> ui.access(() -> [update screen]
                                  () -> log.error(...));

The code behind [update screen]
then calls
which has no effect.

It’s hard to tell without an example to reproduce the issue.

refreshItem should refresh the item that is “equal”. So maybe the equals and hashcode in your bean class has not been overridden (which could cause an error like this) or does not cover all the cases.


While my objects derive from a common AbstractEntity where I had defined a proper equals and hash method in one subclass along the hierarchy chain had stupidly declared Lombok’s @EqualsAndHashCode which caused those methods to be overridden (obviously leading to wrong results).
Removing that got things immediately working and all “odd” effects gone!

Superb! Thanks a million! I owe you!

Great :slight_smile:

Everybody is getting caught one day because of Lombok :slight_smile: