John
John

Reputation: 477

How to manage sessions in Vaadin 10?

I have a web page in Vaadin 10 that process files. How do I make different user have different sessions? When I try to open my page in different browsers to process files I get:

java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.

I can't find any useful information or tutorial in official documentation. Currently I look through Baker App - but I can't find there anything about sessions either.

Vaadin Version: 10.0.0.rc3
Spring Boot Version: 2.0.3.RELEASE
Java: 1.8

Upvotes: 4

Views: 2635

Answers (1)

Mehdi Javan
Mehdi Javan

Reputation: 1091

Actually, it is mentioned in the documentation. Take a look at its Javadoc here. Based on that document, you need to access session like this:

String someValue = null;
session.lock();
try {
    someValue = session.getAttribute("SomeKey");
} finally {
    session.unlock();
}

The complete Javadoc of different versions of Vaadin framework can be seen here.

By the way, I suggest you use the latest version of Vaadin flow which is 10.0.1

Upvotes: 4

Related Questions