This content has been marked as final.
Show 3 replies
-
1. Re: Handling PortalSessionEvent.SESSION_DESTROYED event
je.a.le May 6, 2009 4:38 AM (in response to aspdeepak)Why not using a portalsession attribute ??
login -> set
logout or session expired -> unset
in your portlet, redirect to the appropriate jsp according of this attribute state. -
2. Re: Handling PortalSessionEvent.SESSION_DESTROYED event
aspdeepak May 12, 2009 6:56 AM (in response to aspdeepak)Thanks for your reply.
But my problem was to redirect the user to a automatically to a specified page, lets say login page.
Also I tried using filters, but after session expiration, those filters could'nt be reached.
I have solved this problem in a much simpler way, using javascript.
All you need to do is just add this script to index.jsp of your respective layout folder since it is the container for all your portlets<script type="text/javascript"> var timerId = null; var ttl = <%= request.getSession().getMaxInactiveInterval() * 1000 %>; function portalSessionTimeout() { alert('session expired'); window.location.reload(); // if you need specific page redirection //window.location.replace('<PAGE_URL>'); //window.focus(); } function initialSessionTimeout(){ //alert('initialSessionTimeout()' + ttl ); timerId = setTimeout('portalSessionTimeout()',ttl); } function resetSessionTimeout(){ clearTimeout(timerId); timerId = setTimeout('portalSessionTimeout()',ttl); } </script>
you need to invoke the initialSessionTimeout() in elements onload<body id="body" onload="initialSessionTimeout()">
Note:
if you have partial refresh enabled don't forget to call resetSessionTimeout() on each of your form submits (within the portlets) that may lead to inter portlet communications
Reason:
Remember IPC calls may lead to partial refersh and not the complete page reload, so the the ttl has to be reset, else even if the session is alive the page will be redirected because of wrong ttl -
3. Re: Handling PortalSessionEvent.SESSION_DESTROYED event
aspdeepak May 12, 2009 7:15 AM (in response to aspdeepak)But my problem was to redirect the user to a automatically to a specified page, lets say login page.
Means that the redirection need not require any user interaction.
Also some of the form submit buttons, that leads to IPC, becomes unresponsive after session timeout; due to partial refresh.
So that only I chose for java script.