-
1. Re: ViewExpiredException - conditional redirect
billevans Jun 23, 2009 1:15 AM (in response to pramod_bs)That's funny!! I want to do exactly the same thing!!
I will post the answer here if I find out before you!
-
2. Re: ViewExpiredException - conditional redirect
billevans Jun 23, 2009 1:19 AM (in response to pramod_bs)By the way, I did try following the advice in section 6.7 of the Seam reference guide:
6.7. Fine-grained files for definition of navigation, page
actions and parameters
If you have a lot of different page actions and page parameters, or even just a lot of navigation
rules, you will almost certainly want to split the declarations up over multiple files. You can define
actions and parameters for a page with the view id /calc/calculator.jsp in a resource named
calc/calculator.page.xml.... but it didn't work... :(
-
3. Re: ViewExpiredException - conditional redirect
billevans Jun 23, 2009 5:49 PM (in response to pramod_bs)Here's a way to do it:
In pages.xml:
<exception class="javax.faces.application.ViewExpiredException">
<redirect view-id="#{facesContext.externalContext.requestServletPath}">
<message severity="INFO">Your session has timed out, please log in again</message>
</redirect>
</exception>And for each of your pages:
<page view-id="/main/main.xhtml" login-required="true">
<action execute="#{exceptionHandler.redirectOnViewExpired}"/>
</page>Where
exceptionHandler
is the name of an application-scoped class:
@Name("exceptionHandler")
@Scope(ScopeType.APPLICATION)
@Startup
public class ExceptionHandler {
//
@In(value="org.jboss.seam.handledException", required=false) private Exception exception;
@In private Redirect redirect;
public void redirectOnViewExpired() {
if (this.exception != null &&
(exception instanceof ViewExpiredException exception instanceof NotLoggedInException)) {
//
String currentViewId = FacesContext.getCurrentInstance().getExternalContext().getRequestServletPath();
if (currentViewId.endsWith("blahblah.seam"))
redirect.setViewId("/expired.xhtml");
else {
redirect.setViewId("/login.xhtml");
}
redirect.execute();
}
}
}Hope this helps.
-
4. Re: ViewExpiredException - conditional redirect
billevans Jun 23, 2009 5:52 PM (in response to pramod_bs)Whoops!! Sorry about the formatting... you should be able to dissect the solution though!
-
5. Re: ViewExpiredException - conditional redirect
pramod_bs Jun 23, 2009 6:19 PM (in response to pramod_bs)Thanks for your input. Don't you think we should have something like:
<exception class="javax.faces.application.ViewExpiredException"> <navigation from-view-id="/*.xhtml"> <redirect view-id="/home.xhtml"> <message severity="warn">Your session has timed out, please try again</message> </redirect> </navigation> <navigation from-view-id="/admin/*.xhtml"> <redirect view-id="/home.xhtml"> <message severity="warn">Your session has timed out, please try again</message> </redirect> </navigation> </exception>
SEAM GURUS.. Does this makes sense.