Customizing redirect.captureCurrentView in case of errors
infinity2heaven Jun 13, 2008 9:35 PMI'm using Seam's authentication with a redirect view filter, it works perfectly fine.
components.xml
<event type="org.jboss.seam.security.notLoggedIn"> <action execute="#{redirect.captureCurrentView}"/> </event> <event type="org.jboss.seam.security.postAuthenticate"> <action execute="#{redirect.returnToCapturedView}"/> </event>
However, I have a problem, when a redirect should occur to a specified page, in case of recoverable exceptions/errors. For ex,
pages.xml
.... .... <exception class="org.jboss.seam.security.NotLoggedInException"> <redirect view-id="/login.xhtml"> <message severity="INFO">You must be logged in to perform this action</message> </redirect> </exception> <exception class="org.jboss.seam.security.AuthorizationException"> <redirect> <message severity="INFO">You don't have permission to do this</message> </redirect> </exception> <exception class="org.jboss.seam.framework.EntityNotFoundException"> <redirect view-id="/error.xhtml"> <message severity="ERROR">Not found</message> </redirect> </exception> <exception class="javax.persistence.OptimisticLockException"> <end-conversation/> <redirect view-id="/error.xhtml"> <message severity="ERROR">Another user changed the same data, please try again</message> </redirect> </exception> <exception class="javax.faces.application.ViewExpiredException"> <redirect view-id="/error.xhtml"> <message severity="ERROR">Your session has timed out, please login again</message> </redirect> </exception> <exception class="java.lang.Exception"> <end-conversation/> <redirect view-id="/error.xhtml"> <message severity="ERROR">An Application Error has occurred</message> </redirect> </exception>
So, if you have encounter a session timeout, user is redirected to an error page simply puts a message to log back in. the url opens a login page and after successful login -- takes it back to the error page! (because captureCurrentView returns the previous error.xhtml).
My question is -- How do I override this rule in components.xml (in my case, whenever the captureCurrentView =/error.xhtml, I need to redirect to home.xhtml)