Persistence Question


Pardon me for being thick, but for the life of me I cannot figure out how Vaadin handles persistence across page refreshes, or how I get/set things like cookies in order to determine if a user has logged in.

I’ve read the Vaadin book (well, skimmed thoroughly) and combed the forums, but even the login examples don’t discuss persistence.

From what I’ve been able to learn, it seems as if the state of the Application is automatically persisted between page refreshes, but I want to confirm this before I start to craft some basic architecture.



You’ve learned correctly, Vaadin does indeed handle all the session persistence for you in the server, no need to worry about that, just think of HTTP as a sort of a render stream between user events. Take page-refresh-persistence as granted.

And what we usually like to say, just think like you’d be developing a regular desktop app, and store all data, such as login information, in regular POJO’s.

Jouni said it already, but I’ll take this opportunity to practice explaining this, since this question is asked a lot.

Pretend it’s a desktop application - data is persistent in the application, until the application is closed (i.e for the duration of a ‘session’).
Data that must persist after the application is closed (between sessions), must explicitly be persisted, e.g to a database.

Note that static variables are shared among all users - this differs from a desktop application.

Cookies are used under the hood to track user’s sessions, but generally you never need to use cookies.

Best Regards,