Preserve View on change to other view

Hi, I would like to have one grid/search view, loading from a larger database, and select an entity, to be shown in another detail view. But even with @PreserveOnRefresh, when I switch from grid/search view to the detail view and then back, all in the grid listed entities are gone, the view is refreshed, the textfields do not show the user entered content anymore. I come from Vaadin 8, and there the views keep the entered data and state, if I am not mistaken. What do I do wrong or miss here ?
best regards

This should still be the case but it depends on how you have build your views. If you add / refresh the data in on attach, on before enter or after - basically in any listener - than those parts are called a second time when re-entering the view. You also don’t really need PreserveOnRefresh in your case, but an UIScoped View.

Yes, PreserveOnRefresh does nothing in this case

Regardless of the Vaadin version

Hi, ah, indeed, the Vaadin 8 code is so old. I did use the attach method of the AbstractFormView, which is the view, that is refreshed and kept the internal layout alive, if existed. Thx for the quick answers.

There is a discussion about this here: @PreserveOnRefresh or alternative missing · Issue #3522 · vaadin/flow · GitHub

Thx, I looked at the old vaadin 8 code. There the Layout had the function attach, which was overwritten to check, if another view already exists, as a spring managed component. That view kept the entered data.
@Override
public void attach() {
super.attach();
logger.info(“Attaching form”);
// Add tcatalogue table to this view
if (this.view == null) {
this.view = new FooBarEditView(service);
addComponent(view);
}

} 

so it was not created, when entering the old view. Is there a way in Vaadin 23 or 24, as I did not find the attach method anymore, only the events for onAttach and onDetach.

onAttach is still present

yes, but am I able to implement the same functionality ?! I will check, if it is possible. Thx