Pass information to new web-browser window/tab being opened with BrowserWindowOpener in Vaadin 8

后端 未结 2 1765
小蘑菇
小蘑菇 2021-01-28 20:08

In Vaadin 8, we can let the user open a new tab/window within their web browser by clicking a button that has been associated with a BrowserWindowOpener. As discussed in the man

2条回答
  •  清歌不尽
    2021-01-28 20:59

    There are basically three approaches you can use, and combinations of these

    1. Use URI parameters. As you mentioned, this is limited to String type data.

      • You can read the URI fragment in UI with e.g. String uriFragment = Page.getCurrent().getUriFragment();
      • You can read URI parameter using VaadinRequest.getParameter(), VaadinRequest is given as parameter in init(...) of main UI
    2. UI's in different browser tabs share the same Vaadin session. That gives some tools, namely

      • You can use session attributes, i.e. VaadinSession.getCurrent().getAttribute(…) and VaadinSession.getCurrent().setAttribute(…)

      • If you use CDI or Spring, you can Inject / Autowire @VaadinSessionScoped bean. The instance is then bound to Session and hence shared between the tabs.

    3. Read data from database (possibly using 1. and/or 2. as help for keys)

提交回复
热议问题