用户离开页面时在Seam中结束对话 [英] End Conversation in Seam when the user leaves the page

查看:124
本文介绍了用户离开页面时在Seam中结束对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户离开页面时,是否可以通过某种方式结束Seam 2中的对话?我知道,我当然可以在导航规则中结束对话(请参见这篇文章 ),但是当用户在浏览器的地址栏中输入网址时,我想结束对话.

Is there some way to end a conversation in Seam 2 when the user leaves the page? I know, that I can of course end a conversation in the navigation rules( see this post), but I want to end a conversation when the user enters an url in the address bar of the browser.

这可以通过Javascript实现吗(例如,使用onbeforeunload)?但是如何通过javascript停止对话?

Could this be achieved via Javascript (for example with onbeforeunload)? But how to stop a conversation via javascript?

推荐答案

当用户在 浏览器的地址栏.

I want to end a conversation when the user enters an url in the address bar of the browser.

这是否可以通过Javascript实现(例如 onbeforeunload)?但是如何通过javascript停止对话?

Could this be achieved via Javascript (for example with onbeforeunload)? But how to stop a conversation via javascript?

您可以使用JavaScript实施onbeforeunload事件,并使用AJAX交流离开该网站的用户并结束所有对话.但是,我不建议您使用此解决方案,因为您不能依赖浏览器上发生的事件,Javascript不是一个好的选择,因为您可以在客户端禁用它(不仅如此,而且浏览器可能会崩溃,网络连接可能会断开,等等.)

You could use JavaScript to implement an onbeforeunload event and use AJAX to communicate the user leaving to the site and end all your conversations. However, I don't recommend you this solution because you cannot rely on a event happening on the browser, Javascript is not a good option, since you can disable it client-side (Not only that, but the browser may crash, the network connection may drop, etc..)

我认为实现此目的的另一种方法是在服务器上设置接缝conversation timeout.您可以尝试减少超时,以便在用户离开您的页面时更快地关闭不活动的会话.

I think an alternative aproach to do this is by setting a seam conversation timeout on the server. You can try and reduce the timeout in order to close inactive conversation faster, when the user leave your page.

配置会话超时时间可以通过components.xml中的以下操作完成:

Configuring the conversation-timeout period can be accomplished through the following in your components.xml:

<core:manager conversation-timeout="700000" />

请注意,对话超时仅影响background对话,foreground对话仅在与您的要求相关的对话超时时才会超时.

Notice that conversation-timeout only affects background conversations, foreground conversation will only timeout when the session times out which is relevant for your requirements.

有关会话超时的更多信息,请参见以下文章.

More information about conversation time out can be found in this article.

这篇关于用户离开页面时在Seam中结束对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆