Book Image

Data-Centric Applications with Vaadin 8

By : Alejandro Duarte
Book Image

Data-Centric Applications with Vaadin 8

By: Alejandro Duarte

Overview of this book

Vaadin is an open-source Java framework used to build modern user interfaces. Vaadin 8 simplifies application development and improves user experience. The book begins with an overview of the architecture of Vaadin applications and the way you can organize your code in modules.Then it moves to the more advanced topics about advanced topics such as internationalization, authentication, authorization, and database connectivity. The book also teaches you how to implement CRUD views, how to generate printable reports, and how to manage data with lazy loading. By the end of this book you will be able to architect, implement, and deploy stunning Vaadin applications, and have the knowledge to master web development with Vaadin.
Table of Contents (11 chapters)

Using the HTTP session and cookies to identify users

One way of keeping track of the state of a web application is by making use of the HTTP session. The currently authenticated user is part of the state of the application and can be stored in the HTTP session. In Vaadin applications, you can store values in the HTTP session by using the VaadinSession.setAttribute(String, Object) method. The first parameter is a custom identifier for the value which is specified using the second parameter. For example, we can store the number 777 in an attribute with the name number in the HTTP session as follows:

VaadinSession.getCurrent().setAttribute("number", 777);

You can remove the value from the session by passing null:

VaadinSession.getCurrent().setAttribute("number", null);
...