Jef*_*ong 1 session spring vaadin
我想为我的应用程序添加用户会话支持.由于重新加载页面将重新启动应用程序,甚至打开另一个浏览器选项卡将导致原始的"不同步"问题.
我是否需要为每次登录创建一个独立的窗口,或者是否有我可以使用的插件,或者如果我将它设为Spring + Vaadin应用程序,它会解决这个问题吗?
使用Vaadin Framework创建的应用程序是自动状态的,因此除非URL中包含?restartApplication参数,否则应用程序应保持其状态.
要在同一会话中支持多个浏览器选项卡/窗口,必须在Application类中重写getWindow(String name),以便为每个浏览器选项卡/窗口返回一个新的Window实例:
@Override
public Window getWindow(String name) {
// If the window is identified by name, we are good to go
Window w = super.getWindow(name);
// If not, we must create a new window for this new browser window/tab
if (w == null) {
w = new CalcWindow();
// Use the random name given by the framework to identify this
// window in future
w.setName(name);
addWindow(w);
// Move to the url to remember the name in the future
w.open(new ExternalResource(w.getURL()));
}
return w;
}
Run Code Online (Sandbox Code Playgroud)
有关Vaadin多窗口支持的更多信息,请参阅此Wiki页面.
| 归档时间: |
|
| 查看次数: |
6969 次 |
| 最近记录: |