com.sun.faces.enableRestoreView11Compatibility在JSF 1.2中使用的是什么 [英] com.sun.faces.enableRestoreView11Compatibility what use instead in JSF 1.2
问题描述
当我有javax.faces.application.ViewExpiredException时我想将用户发送到登录页面。
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
sessionExpired.jsf
....
<c:redirect url="/index.jsf" />
但是enableRestoreView11Compatibility是JSF 1.1中使用的方法,什么是JSF 1.2的解决方案?
but enableRestoreView11Compatibility is method that was used in JSF 1.1, what is solution for JSF 1.2?
推荐答案
com.sun.faces.enableRestoreView11Compatibility
是一个JSF 1.2设置告诉JSF 1.2表现得像JSF 1.1。
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
表示不要抛出 ViewExpiredException
;相反,如果旧视图已过期,只需创建一个新视图。
com.sun.faces.enableRestoreView11Compatibility
== true
means "do not throw a ViewExpiredException
; instead, just create a new view if the old one has expired."
这可能会产生不利行为,因为它是一个新视图,通常在视图中的项目(如州)不再存在。
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.
默认的JSF 1.2行为在中定义规范如下:
The default JSF 1.2 behaviour is defined in the spec as this:
如果请求是回发,请调用
ViewHandler.restoreView()
,传递FacesContext
当前请求和视图标识符的实例,并为恢复的视图返回UIViewRoot
。如果从ViewHandler.restoreView()
返回的值为null,则抛出一个ViewExpiredException
,并显示相应的错误消息。 javax.faces.application.ViewExpiredException是一个
FacesException`,必须抛出该信号以向应用程序发出信号,表明未为视图标识符返回预期的视图。应用程序可以选择基于此异常执行某些操作。
If the request is a postback, call
ViewHandler.restoreView()
, passing theFacesContext
instance for the current request and the view identifier, and returning aUIViewRoot
for the restored view. If the return fromViewHandler.restoreView()
is null, throw aViewExpiredException
with an appropriate error message. javax.faces.application.ViewExpiredExceptionis a
FacesException` 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.
要有 ViewExpiredException
在视图过期时抛出,删除 com.sun.faces.enableRestoreView11Compatibility
参数或将其设置为 false
。
To have a ViewExpiredException
thrown when the view expires, remove the com.sun.faces.enableRestoreView11Compatibility
parameter or set it to false
.
com.sun
namespace表示该参数是Sun / Mojarra和派生的特定于实现的设置,因此它可能不适用于所有JSF实现。
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.
这篇关于com.sun.faces.enableRestoreView11Compatibility在JSF 1.2中使用的是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!