Vaadin Spring Scopes

    Scopes

    As in programming languages, where a variable name refers to a unique object within the scope of the variable, an object has unique identity within a scope in Spring. However, instead of identifying the objects by variable names, they are identified by their type (object class) and any qualifiers they may have.

    In addition to standard Spring scope the Spring add-on introduces two new scopes: and UIScope.

    Java

    In this example the same instance of SessionService will be used as long as we access the application from the same Vaadin session since it’s session scoped. E.g. if you open the root target in one tab and the editor target in another tab, then the shown text will be the same for both. It happens because the session is the same even though the tabs (and UI instances) are different.

    Note
    Please refer to section of Application Lifecycle tutorial for details about the UI lifecycle.

    Java

    Now if you open two browser tabs, the text in these will be different since the instances are different. But if you navigate to the Editor instance via the router (or the UI instance which delegates navigation to the router) then the text will be the same.

    So inside the same UI instance the same bean instance with @UIScope is used.