Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Root state preservation
I just started using Vaadin, and I use Vaadin 7.0.0.alpha1.
I'm trying to preserve the Root state for browser refresh & browser tabs.
I refered Migration Guide and tried Application.setRootPreserved(true), but it is not working!
Also, the WindowRefactoring mentions that 'Developer can enable Root state preservation by overriding Application.getRoot and keeping track of window.name', I tried doing this but got NPE on browser refresh -
java.lang.NullPointerException
at com.vaadin.Application.getRootId(Application.java:2322)
I also noticed that on every refresh the http session id keeps changing.
Is there any solution for this issue? appreciate if there is any sample/demo web application with this implementation.
Thanks.
jasphior g:
I refered Migration Guide and tried Application.setRootPreserved(true), but it is not working!
Got this working!! Found what I was doing wrong earlier.. (not sure whether this is the correct way, but here is how it worked)
1. Create a window in the Application's init method (this will be our main window) and add our root as its content
Window window = new Window();
home = new SimpleRoot();
//home.getApplication().setRootPreserved(true); [this won't work, so have to do this as in root's init]
//setRootPreserved(true);[this won't work either]
window.setContent(home);
2. In the root's init method set
getApplication().setRootPreserved(true);
Hope this helps people like me who doesn't read full document! :)
For now, this is working fine for me. So marking it as an answer.