开发者

com.sun.faces.enableRestoreView11Compatibility what use instead in 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" />

b开发者_JAVA技巧ut enableRestoreView11Compatibility is method that was used in JSF 1.1, what is solution for JSF 1.2?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜