Here is sample code to handle sessiontimeout in dojo dialog for websphere portal environment
In case on user's session is invalidated.. user will be directed to login screen.
--------------------------------------------------------------------
<portlet:namespace/>checkUserSession("/wps/myportal","<portlet:resourceURL id="showSearchResult"/>");
function <portlet:namespace/>checkUserSession(checkSessionURL,dialogURL){
window.dialogURL=dialogURL;
dojo.xhrGet({url:checkSessionURL, preventCache:true, handleAs:"text", timeout:5000, load:<portlet:namespace/>isSessionActive, error:<portlet:namespace/>isSessionActive});
}
function <portlet:namespace/>isSessionActive(response,ioArgs) {
if(ioArgs.xhr.getResponseHeader('Content-Location').indexOf("/wps/portal")!=-1 || ioArgs.xhr.status!=200) {
window.location.href=ioArgs.xhr.getResponseHeader('Content-Location');
} else {
dijit.byId('clientFinderSearchResults').attr("href",window.dialogURL);
dijit.byId('clientFinderSearchResults').show();
}
}
--------------------------------------------------------------------
In case on user's session is invalidated.. user will be directed to login screen.
--------------------------------------------------------------------
<portlet:namespace/>checkUserSession("/wps/myportal","<portlet:resourceURL id="showSearchResult"/>");
function <portlet:namespace/>checkUserSession(checkSessionURL,dialogURL){
window.dialogURL=dialogURL;
dojo.xhrGet({url:checkSessionURL, preventCache:true, handleAs:"text", timeout:5000, load:<portlet:namespace/>isSessionActive, error:<portlet:namespace/>isSessionActive});
}
function <portlet:namespace/>isSessionActive(response,ioArgs) {
if(ioArgs.xhr.getResponseHeader('Content-Location').indexOf("/wps/portal")!=-1 || ioArgs.xhr.status!=200) {
window.location.href=ioArgs.xhr.getResponseHeader('Content-Location');
} else {
dijit.byId('clientFinderSearchResults').attr("href",window.dialogURL);
dijit.byId('clientFinderSearchResults').show();
}
}
--------------------------------------------------------------------
No comments:
Post a Comment