com.sun.faces.enableRestoreView11Compatibility 在 JSF 1.2 中使用什么

发布于 2024-08-11 01:08:01 字数 693 浏览 9 评论 0原文

当我有 javax.faces.application.ViewExpiredException 时,我想将用户发送到登录页面。

web.xml

...
    <context-param>
        <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
        <param-value>true</param-value>
    </context-param>
...
 <error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/errors/sessionExpired.jsf</location>
 </error-page>

sessionExpired.jsf

....
<c:redirect url="/index.jsf" />

但 enableRestoreView11Compatibility 是 JSF 1.1 中使用的方法,JSF 1.2 的解决方案是什么?

When I have javax.faces.application.ViewExpiredException I want to send user to login page.

web.xml

...
    <context-param>
        <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
        <param-value>true</param-value>
    </context-param>
...
 <error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/errors/sessionExpired.jsf</location>
 </error-page>

sessionExpired.jsf

....
<c:redirect url="/index.jsf" />

but enableRestoreView11Compatibility is method that was used in JSF 1.1, what is solution for JSF 1.2?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽你眉间 2024-08-18 01:08:01

com.sun.faces.enableRestoreView11Compatibility 是一个 JSF 1.2 设置,它告诉 JSF 1.2 的行为类似于 JSF 1.1。

com.sun.faces.enableRestoreView11Compatibility == true 表示“不要抛出 ViewExpiredException;相反,如果旧视图存在,只需创建一个新视图已经过期了。”

IBM 关于 JSF 1.1 行为的注释说:

这可能会产生不良行为,因为它是一个新视图,并且视图中通常存在的项目(例如状态)不再存在。

默认的 JSF 1.2 行为在规范中定义如下:

如果请求是回发,则调用 ViewHandler.restoreView(),传递当前请求的 FacesContext 实例和视图标识符,并返回 UIViewRoot 用于恢复的视图。如果 ViewHandler.restoreView() 返回为 null,则抛出 ViewExpiredException 以及相应的错误消息。 javax.faces.application.ViewExpiredException是一个FacesException`,必须抛出该异常以向应用程序发出信号,表明未返回视图标识符的预期视图。应用程序可以选择根据此异常执行某些操作。

要在视图过期时引发 ViewExpiredException,请删除 com.sun.faces.enableRestoreView11Compatibility 参数或将其设置为 false< /代码>。


com.sun 命名空间表明该参数是 Sun/Mojarra 和派生的特定于实现的设置,因此它可能不适用于所有 JSF 实现。

com.sun.faces.enableRestoreView11Compatibility is a JSF 1.2 setting that tells JSF 1.2 to behave like JSF 1.1.

com.sun.faces.enableRestoreView11Compatibility == true means "do not throw a ViewExpiredException; instead, just create a new view if the old one has expired."

The IBM notes on the JSF 1.1 behaviour say:

This can have adverse behaviors because it is a new view, and items that are usually in the view, such as state, are no longer be there.

The default JSF 1.2 behaviour is defined in the spec as this:

If the request is a postback, call ViewHandler.restoreView(), passing the FacesContext instance for the current request and the view identifier, and returning a UIViewRoot for the restored view. If the return from ViewHandler.restoreView() is null, throw a ViewExpiredException with an appropriate error message. javax.faces.application.ViewExpiredExceptionis aFacesException` that must be thrown to signal to the application that the expected view was not returned for the view identifier. An application may choose to perform some action based on this exception.

To have a ViewExpiredException thrown when the view expires, remove the com.sun.faces.enableRestoreView11Compatibility parameter or set it to false.


The com.sun namespace suggests that the parameter is a Sun/Mojarra and derived implementation-specific setting, so it probably will not work with all JSF implementations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文