问题
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?
回答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
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 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.
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.
来源:https://stackoverflow.com/questions/1715985/com-sun-faces-enablerestoreview11compatibility-what-use-instead-in-jsf-1-2