在后台处理ViewExpiredException并还原表单值 [英] Handle ViewExpiredException in the background and restore form values

查看:107
本文介绍了在后台处理ViewExpiredException并还原表单值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在无需数据库,素数和保持会话有效"的解决方案,以在恢复表单输入时在后台静默地防止或处理ViewExpiredException?

例如,拥有保持登录的cookie"的用户可能不希望重定向到某种错误页面或开始页面;他填写了一些表单值,在一小时后返回,然后,当他提交表单时,将使用先前的输入重新创建相同的视图,并再次重新执行基础requestscope-bean的Submit-action. /p>

我已经注意到了无所不包和莫吉拉斯(Mojarras)

  <o:enableRestorableView />
  <f:view transient="true"> 

但是当我们谈论永久登录用户时,如果这是正确的方法,我不敢肯定.

感谢您指向正确的方向.

解决方案

使用先前的输入重新创建相同的视图,并重新执行基础requestscope-bean的Submit-action

对于此要求,透明地重新创建和恢复绑定到 request 作用域bean的过期JSF表单,如<f:view transient="true">所示的无状态JSF是正确的解决方案.

在此特定情况下,不需要 <o:enableRestorableView> .它仅用于透明地重新创建和还原与 view 作用域bean绑定的过期JSF表单.您仍然只需根据其@PostConstruct中的请求参数手动填充视图范围的Bean属性.

换句话说,您不需要混合使用这些解决方案.从技术上讲,这是没有意义的,因为在无状态的JSF中,视图作用域的bean毫无用处,它们的行为就像请求作用域的bean.

另请参见:

Is there a database-, primefaces- and "keep-session-alive"-free solution to prevent or to handle a ViewExpiredException silently in the background while restoring the form-inputs?

for example a user with a "stay logged-in cookie" would prefer not to be redirected to some kind of an error- or start-page; he fills out some form values, comes back in an hour and then, when he submits the form, the same view is re-created with its previous inputs and the submit-action of the underlying requestscope-bean is re-executed again.

i already took notice of omnifaces and mojarras

  <o:enableRestorableView />
  <f:view transient="true"> 

but as we talk about permanent logged-in users, i am not shure, if this would be the right approach.

thanks for pointing into the right direction.

解决方案

the same view is re-created with its previous inputs and the submit-action of the underlying requestscope-bean is re-executed again

For exactly this requirement, transparently recreating and restoring an expired JSF form tied to a request scoped bean, stateless JSF as in <f:view transient="true"> is the correct solution.

The <o:enableRestorableView> is unnecessary in this specific case. It is only useful for transparently recreating and restoring an expired JSF form tied to a view scoped bean. You only still have to manually populate the view scoped bean properties based on request parameters in its @PostConstruct.

In other words, you don't need to mix those solutions. It does technically not make sense as view scoped beans are useless anyway in stateless JSF, they will behave like request scoped beans.

See also:

这篇关于在后台处理ViewExpiredException并还原表单值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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