您现在的位置是:首页 > 电脑 > 

在Vaadin Web应用程序中分离事件未被调用(Detach event in Vaadin web app not getting called)

2025-07-21 23:55:44
在Vaadin Web应用程序中分离事件未被调用(Detach event in Vaadin web app not getting called) 我的问题源于一个几乎与此处相同的问题(最终没有得到满意的答案): https://vaadin.com/forum/thread/ 就像这个人一样,我希望在关闭浏览器后我的应用程序被打
在Vaadin Web应用程序中分离事件未被调用(Detach event in Vaadin web app not getting called)

我的问题源于一个几乎与此处相同的问题(最终没有得到满意的答案):

https:///forum/thread/192610

就像这个人一样,我希望在关闭浏览器后我的应用程序被打开,分离事件会触发; 然而,这并没有发生。 我已经尝试添加一个分离侦听器,覆盖分离方法,并同时执行这两个操作,但它们都没有成功。 至于我怎么知道没有调用detach事件,我的detach事件是一个简单的print语句 - 它没有显示在输出中。

请注意,就像前面提到的线程一样,我已经设置了心跳间隔(在我的情况下为2秒)并将closeIdelSessi设置为true。 所以,我想我只需要等待六秒钟,但事实并非如此。

My question stems from an issue almost identical to the one here (which did not end up getting a satisfactory answer):

https:///forum/thread/192610

Like this person, I expected that upon closing the browser that my app was open in, a detach event would proc; however, this did not happen. I've tried adding a detach listener, overriding the detach method, and doing both at the same time, but none of them were successful. As for how I know the detach event was not called, my detach event is a simple print statement - that does not show up in the output.

ote that like in the aforementioned thread, I've already set the heartbeat interval (2 seconds in my case) and set closeIdelSessi to be true. So, I thought I would just have to wait six seconds, but that's certainly not been the case.

最满意答案

当我尝试这个(到下面代码的基本部分)时,最终会调用detach()。 我用Jetty运行它,我没有触及它的默认值。 关闭浏览器后约需45分钟,当我看到“Detach called”登录控制台时。 所以是的,时间很长。 原因是只有在HttpSession过期后才会清除最后一个UI(这取决于应用程序容器等设置)。 如果你想更快地强制清理,你需要使用https:///directory/component/cleanupservlet-add-on

@Push @SuppressWarnings("serial") public class DemoUI extends UI { @WebServlet(value = "/*", asyncSupported = true) @VaadinServletConfiguration(productionMode = false, ui = , heartbeatInterval=5, closeIdleSessi=true) public static class Servlet extends VaadinServlet { } @Override public void detach() { println("Detach called"); } @Override protected void init(VaadinRequest vaadinRequest) { ... }

When I try this (find the essential parts of the code below), the detach() is eventually being called. I run this with Jetty, and I did not touch its default. It tooks some ~45 minutes after closing the Browser, when I saw "Detach called" logged on cole. So yes, the time is lengthy. The reason is that the last UI is cleaned up only after HttpSession is expired (which depends on application container etc. settings). If you want to do forced clean up quicker, you need to use https:///directory/component/cleanupservlet-add-on

@Push @SuppressWarnings("serial") public class DemoUI extends UI { @WebServlet(value = "/*", asyncSupported = true) @VaadinServletConfiguration(productionMode = false, ui = , heartbeatInterval=5, closeIdleSessi=true) public static class Servlet extends VaadinServlet { } @Override public void detach() { println("Detach called"); } @Override protected void init(VaadinRequest vaadinRequest) { ... }

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/654035.html

相关标签:无
上传时间: 2023-07-28 12:48:59
留言与评论(共有 12 条评论)
本站网友 breakingnews
3分钟前 发表
and I did not touch its default. It tooks some ~45 minutes after closing the Browser
本站网友 雅诗兰黛眼霜适合什么年龄
3分钟前 发表
并同时执行这两个操作
本站网友 太和洞久咳丸
19分钟前 发表
and I did not touch its default. It tooks some ~45 minutes after closing the Browser
本站网友 集团
12分钟前 发表
这并没有发生
本站网友 马佳佳商城
1分钟前 发表
the detach() is eventually being called. I run this with Jetty
本站网友 海悦花园
7分钟前 发表
你需要使用https
本站网友 王智胸围
18分钟前 发表
最终会调用detach()
本站网友 高青二手房
27分钟前 发表
My question stems from an issue almost identical to the one here (which did not end up getting a satisfactory answer)
本站网友 溯游从之
20分钟前 发表
closeIdleSessi=true) public static class Servlet extends VaadinServlet { } @Override public void detach() { println("Detach called"); } @Override protected void init(VaadinRequest vaadinRequest) { ... }
本站网友 日薄西山
26分钟前 发表
但它们都没有成功
本站网友 彭州租房信息
4分钟前 发表
///directory/component/cleanupservlet-add-on @Push @SuppressWarnings("serial") public class DemoUI extends UI { @WebServlet(value = "/*"