Is there a @PreserveOnRefresh alternative in Vaadin 10?

I’m investigating the workload of upgrading my Vaadin 8 application to Vaadin 10, and the first thing I’m running into is the lack of @PreserveOnRefresh
My application is UI dynamicly from calls to a backend server, so the Route concept and parameters do not help me much.
So my question is there a @PreserveOnRefresh alternative?

Hi Thomas. Unfortunately there is no replacement for it. Actually we don’t even have an issue for it yet in github.com/vaadin/flow.

If you would need this, please create an issue and describe your use case there; what value would it bring to you. Then it will be competing against other improvements for getting added to Flow, so everybody who needs it should +1 the issue.

Thanks

Hi Pekka…
Is there some other way to handle browser refreshes without the @PreserveOnRefresh?
Other than rebuilding the UI?

Thanks

Vaadin 14 does come with PreserveOnRefresh.

I have tried PreserveOnRefresh in 14.0.0.beta2
The view is repainted but a new UI instance is getting created on every refresh. I have some stuff attached to the previous UI and also several of my logic have references to the previous UI.

That’s a known limitation of the implementation. It’s mentioned in the documentation here: https://github.com/vaadin/flow-and-components-documentation/blob/master/documentation/advanced/tutorial-preserving-state-on-refresh.asciidoc and here: https://github.com/vaadin/flow-and-components-documentation/blob/master/documentation/migration/3-general-differences.asciidoc . You should store the information that would go to the UI class in Vaadin 7/8 to, for example, the class where you put the @PreserveOnRefresh annotation in V14.

Thanks Olli for the documentation links.
Yes, I need to re-factor my code accordingly.

Noticed one issue. When the view is a Grid and if the Grid has additional headers, those additional header values are disappearing on refresh. Is this a known issue?

At least I didn’t find anything, could you please file a ticket with reproduction instructions at https://github.com/vaadin/vaadin-grid-flow/issues?utf8=✓&q=is%3Aissue+is%3Aopen+preserveonrefresh ?

I have same error with header.
TypeError: window.Vaadin.Flow.contextMenuConnector is undefined
TypeError: this.$connector is undefined
The error has occurred in the JS code: ‘$0, $1, $2, window.Vaadin.Flow.contextMenuConnector.generateItems($0, $1, $2)’

ContextMenu seems to have a bug related to PreserveOnRefresh: https://github.com/vaadin/vaadin-context-menu-flow/issues/86

It will be fixed before V14 stable release.

Until then, as a workaround you can avoid the issue by explicitly adding the ContextMenu component anywhere in the UI.

Olli Tietäväinen:
At least I didn’t find anything, could you please file a ticket with reproduction instructions at https://github.com/vaadin/vaadin-grid-flow/issues?utf8=✓&q=is%3Aissue+is%3Aopen+preserveonrefresh ?

[https://github.com/vaadin/vaadin-grid-flow/issues/692]
(https://github.com/vaadin/vaadin-grid-flow/issues/692)

Thanks!