[jboss-user] [JBoss Portal] - Re: Handling PortalSessionEvent.SESSION_DESTROYED event
aspdeepak
do-not-reply at jboss.com
Tue May 12 06:57:03 EDT 2009
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
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4230412#4230412
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4230412
More information about the jboss-user
mailing list