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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1715985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 17:42:17  来源:igfitidea点击:

com.sun.faces.enableRestoreView11Compatibility what use instead in JSF 1.2

javajsfviewexpiredexception

提问by McDowell

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

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

web.xml

网页.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

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?

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

回答by McDowell

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

com.sun.faces.enableRestoreView11Compatibility是一个 JSF 1.2 设置,它告诉 JSF 1.2 表现得像 JSF 1.1。

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

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

The IBM noteson the JSF 1.1 behaviour say:

IBM的笔记对JSF 1.1的行为说:

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 specas this:

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

If the request is a postback, call ViewHandler.restoreView(), passing the FacesContextinstance for the current request and the view identifier, and returning a UIViewRootfor the restored view. If the return from ViewHandler.restoreView()is null, throw a ViewExpiredExceptionwith 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.

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

To have a ViewExpiredExceptionthrown when the view expires, remove the com.sun.faces.enableRestoreView11Compatibilityparameteror set it to false.

ViewExpiredException在视图过期时引发抛出,请删除com.sun.faces.enableRestoreView11Compatibility参数或将其设置为false



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

com.sun命名空间表明参数是Sun /钻嘴鱼科和派生实现特定的设置,所以它可能不会与所有的JSF实现工作。