1

just a question about Vaadin, I searched a lot, without finding a useful information.

I need to know whether a UI has been refreshed when it has NOT @PreserveOnRefresh annotation set (meaning that overriding UI.refresh() will not work for me).

Basically I have a Map which maps a user session id to the opened UIs in the browser, when a new UI is detected I need to add it to the Collection of UIs for the current session.

If the user requests the same UI (same UI implementation mapped by the Servlet @WebServlet configuration) in the browser I need to either add this UI if and only if it is a UI opened in another window of the browser or in another tab, and do nothing or better remove the old UI and put the new UI if the browser window is refreshed.

I know that if I add a @PreservOnRefresh annotation to the UI this will work (but again I need the UI to be not preservable).

So how can I actually do that? I found this implementation (seems a little bit ugly for me) -> http://dev.vaadin.com/ticket/12191#trac-change-5-1374239207261117

Is there another possible way to do that?

Thanks for the attention!

4

2 回答 2

4

刷新时会创建一个新的 UI,所以您可以在 UI 的 init 方法中将 UI 实例添加到地图中吗?

要从地图中移除 UI,您可以通过调用 UI.addDetachListener 方法添加 DetachListener。当 Vaadin 将 UI 与应用程序分离时,将调用此方法。

于 2014-12-11T05:41:49.483 回答
2

只需覆盖refresh()UI班级中的方法。它适用,@PreserveOnRefresh因此您不必重新初始化您的 UI 实例。

@Override
protected void refresh(VaadinRequest request) {
    super.refresh(request);
    // TODO do your thing here
}
于 2016-08-31T10:33:05.413 回答