会话销毁后如何使用Viewscoped bean/viewmap生存(使用客户端保存)? [英] How to survive viewscoped beans/viewmap after session destroy (using client side saving)?

查看:126
本文介绍了会话销毁后如何使用Viewscoped bean/viewmap生存(使用客户端保存)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Myfaces 2.2和客户端状态保存.我看到了ViewScoped bean&删除用户会话后,存储在viewmap中的数据将丢失. 我知道,不确定这是否正确,这是预期的行为,但是如何避免会话销毁后查看过期的异常呢?

I'm using Myfaces 2.2 with Client-side state saving. I see that the ViewScoped beans & data stored in viewmap is lost after the user session is destroyed. I came to know, not sure if it is correct, that this is the expected behavior but then what's the way to avoid view expired exceptions after session destroy?

我的问题是我在一段时间不活动后(例如20分钟后)很快销毁了用户会话,但是我希望即使在此之后(使用客户端保存时),Viewscope数据也能保留下来,以便当用户在会话后回来时销毁,他不需要刷新页面.我不知道为什么&如何执行此操作,但用户可能会忙于阅读网站的某些部分或离开20分钟是很正常的,当他回来时与打开的页面进行交互,在没有状态的情况下我该如何工作? 我认为这是任何公共网站的普遍要求.

My problem is that I destroy the user session pretty quickly after some inactivity period(like after 20 minutes) but I want the viewscope data to survive even after that(when using client saving) so that when the user comes back after session destroy, he doesn't need to do a page refresh. I dont know why & how this is so implemented but It is very normal that the user may be busy reading some section of website or be away for 20 minutes, & as he comes back & interacts with opened pages, how would I make that work without the state ? I think this is a common requirement for any public websites.

如果我使用客户端状态保存功能(因为我的页面仍在工作),我认为内部使用的jsf viewstate不会丢失,但是为什么那些作用域也与viewstate一起序列化到页面的scoped bean一样.

I think the internally used jsf viewstate is not lost, if I use client side state saving(as my pages still work), but then why are those viewscoped beans scoped that were also serialized to page along with the viewstate.

如果这是设计的行为,有什么办法可以使视图范围的数据在会话期满后继续生存?

If this the designed behavior, Is there any way I could make the view scoped data survive session expiration ?

推荐答案

我从myfaces用户邮件列表中得到的答案:

An answer that I got from the myfaces users mailing list:

viewRoot.getAttributes()映射即使在会话销毁后也可以用于保留视域值.因此,不是将值存储到viewRoot.getViewMap(),而是存储在viewRoot.getAttributes()返回的映射中.但是,应注意确保存储的值可序列化.

viewRoot.getAttributes() map could be used to persist the viewscoped values even after session destroys. Thus instead of storing values to viewRoot.getViewMap(), store in the map returned by viewRoot.getAttributes(). However care should to be taken to ensure that the stored values are serializable.

这篇关于会话销毁后如何使用Viewscoped bean/viewmap生存(使用客户端保存)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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