I found out a strange behavior of the grid component. I have app with multiple tabs in each tab can be multiple grids, sometimes i handle some errors by showing dialog in addColumn method. I found out that every created grid are refreshing each time i change UI (by navigating or F5) I have PreserveOnRefresh annotation. So even grids from other tabs that are not visible right now are refreshing and showing me again some dialogs that are implemented in addColumn method in another grid. I have application where users can add new tabs with a lots of grids so after some time they are refreshing a lot of data after each navigation or F5 pressing. Below I'm adding code example:
@Route("test")
@PreserveOnRefresh
public class Test extends Div {
public Test(){
Grid<String> grid1 = new Grid();
List<String> grid1List = new ArrayList<>();
grid1List.add("grid1Element");
grid1.setItems(grid1List);
grid1.addComponentColumn(item -> {
Dialog grid1D = new Dialog(new SpanTrans("Grid1 Dialog"));
grid1D.open();
return new SpanTrans(item);
});
Grid<String> grid2 = new Grid();
List<String> grid2List = new ArrayList<>();
grid2List.add("grid2Element");
grid2.setItems(grid2List);
grid2.addComponentColumn(item -> {
Dialog grid2D = new Dialog(new SpanTrans("Grid2 Dialog"));
grid2D.open();
return new SpanTrans(item);
});
TabSheet tabs = new TabSheet();
tabs.add("Grid1",grid1);
tabs.add("Grid2",grid2);
add(tabs);
}
}
So when i every time i enter each tab the dialog for grid inside this tab is shown. Why isi t hapenning every time shouldnt it be only for the first time until i'm send refresh request from my code if i would like to? And after F5/Refreshing Page both dialogs for both tabs are shown.
I want to refresh grids only when i'm executing refresh from code and not doing it for every created grid whenever UI will change. I'm using Vaadin 23.3.15