@PreserveOnRefresh - Purpose and need??

Hi,

I have a doubt regarding the purpose of @PreserveOnRefresh annotation. What is the purpose of this particular annotation and what are the scenarios in which it has to be used? What are the effects of using/not using this annotation?

Thanks,
Daniccan VP

Hi,

the @PreserveOnRefresh annotation causes the UI instance (and hence the state) to be retained even over page reloads.

For example, if you do not have this annotation and the user reloads the Vaadin application, a new UI instance will be created, its init() method called and essentially all the state is lost. If this annotation is added, a page reload will simply re-render the same UI instance and state to the browser.

-tepi

Hi Teppo,

Thanks for your answer. It cleared my doubt.

-Daniccan.VP

Teppo Kurki:
Hi,

the @PreserveOnRefresh annotation causes the UI instance (and hence the state) to be retained even over page reloads.

For example, if you do not have this annotation and the user reloads the Vaadin application, a new UI instance will be created, its init() method called and essentially all the state is lost. If this annotation is added, a page reload will simply re-render the same UI instance and state to the browser.

-tepi

hi Teppo,I hava a question that I use the @WebServlet and don’t use @PreserveOnRefresh, my app is work but load the app will spend long time about 60 seconds, refresh brower will spend long time about 20 seconds,If I use @WebServlet and use @PreserveOnRefresh,it dosen’t work, can’t goto the init(); do u know why?