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

耗尽温柔 提交于 2019-12-19 06:19:05

问题


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



来源:https://stackoverflow.com/questions/1715985/com-sun-faces-enablerestoreview11compatibility-what-use-instead-in-jsf-1-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!