每个浏览器标签JSF一次会话 [英] One session per browser-tab JSF

查看:71
本文介绍了每个浏览器标签JSF一次会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用我的JSF应用程序进行一些测试,当我在同一Web浏览器中的不同选项卡上进行测试时,所有选项卡中都存在上一个会话.

I was making some test with my JSF-app and when I tried it in the same web-browser on different tabs, in all tabs the last session was present.

如何防止这种情况?

推荐答案

如果不黑客/更改浏览器,这是不可能的.但这真的不重要.如果这会在您的JSF应用程序中造成不直观的行为(例如,一个标签的数据已在另一标签中重新显示),那么您显然是将视图范围的数据存储在会话范围的Bean中.您应该将视图范围的数据存储在视图范围的Bean中.

That isn't possible without hacking/changing the browser. But this really shouldn't matter. If that causes unintuitive behaviour in your JSF application (e.g. data of one tab is been redisplayed in another tab), then you were apparently storing view scoped data in session scoped beans. You should store view scoped data in view scoped beans instead.

或者如果它纯粹是出于测试目的(例如,您只想测试物理上分开的用户会话),则应该使用物理上分开的浏览器.例如.一台Firefox和一台Chrome.

Or if it is purely intended for testing purposes (i.e. you just wanted to test physically separate user sessions), then you should use physically separate browsers. E.g. one Firefox and one Chrome.

或者,如果您绝对需要每个标签页/窗口有一个用户会话",则将登录的用户存储在视图作用域的bean中,而不是会话作用域的bean中,并专门使用ajax回发来浏览页面(SPA -单页应用程序.)

Or if you absolutely need to have "one user session per tab/window", then store the logged-in user in a view scoped bean instead of a session scoped bean and exclusively use ajax postbacks to navigate through pages (SPA - Single Page Application).

  • How to choose the right bean scope?
  • How do servlets work? Instantiation, sessions, shared variables and multithreading
  • How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)

这篇关于每个浏览器标签JSF一次会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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