Skip to Content
Author's profile photo Former Member

Portal user idle timeout using dialog windows – Client side solution

Warning MessageWarningLog Off Message

Abstract 

As per the SAP Note: 982982 there is no standard solution in SAP Portal to Logoff the Portal due to user inactivity. Hence people have been using client side solution to overcome this. Upto certain extent this functionality built using Javascript has been useful. With reference to the Portal timeout solution posted by Arnaud Leymet, this post is an enhancement of the Portal user idle timeout solution.

Background of previous Solution :

If user is idle, then the Portal displays a warning message to the user after a certain period (warning period). In the duration between warning period and actual timeout period, if user intervens and clicks on the Warning message, then Portal timer is updated. Else the Portal still remains idle waiting for user intervention. Hence the actual timeout of the application is happenning only after user intervention. Even if the user has not seen the application for n hours the portal would not have logged off.

Hence to overcome this issue, in place of an alert I have used a dialog window prompting the user to activate the portal and will be displayed for few minutes (timeout period – warning period) after which it closes automatically and logs off the portal. Before logging off it opens a new window informing the user about the session termination due to inactivity. The code has been modified for achieving the same.

Source

Open Mashead PAR file through NWDS.

Create a JS page by name customtimeout.js under scripts folder in the project directory and include the same in Headerivew.jsp page.

Add the below code in customtimeout.js

javascript/customtimeout.js

 

For opening a pop up dialog window in Internet Explorer browser after the warning period, create a JSP page by name IEDialog.JSP and add the below code in it .

IEDialog.jsp

The Portal session will expire in 5 minute(s). Please click [Continue/Logoff] to Re-activate/End the session.

  

For opening a pop up dialog window in other browsers after the warning period, create a JSP page by name FFDialog.JSP and add the below code in it .

FFDialog.JSP

Your session will expire in 5 minute(s). Please click [Continue/Logoff] to Re-activate/End the session.

To display a Logoff message after Portal Log off, create a JSP page by name LogoffMessage add the below code in it . 

The Log off Message is displayed, so that user can identify that its a force log off due to session inactivity.  The HTML code for the same is given below.

LogOffMessage.jsp

The Portal session has been terminated due to inactivity. Please login again.

 

Add the below code towards the end of HeaderiView.jsp

(No change done in this page compared to previous)

PORTAL-INF/jsp/HeaderiView.jsp

 

Note: The Idle warn delay & kick delay values can be changed as per the requirement in

customTimeoutHandler(25, 30) in HeaderiView.jsp.

Result:

After being idle on the portal for 25 minutes , you should obtain a popup like the following:

Dialog Window:

image

Log off message after timeout:

image

It worked for me. Hope you’ll find it useful.

Assigned Tags

      31 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Its a very useful blog, thanks for the detailed steps.
      Author's profile photo Former Member
      Former Member
      Is the code in your HeaderiView.jsp  supposed to be the same as the code in your LogOffMessage.jsp?
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,

      Thanks for informing that. I had problems during posting it, so may be by mistake. 🙂
      Anyways, I have updated the code in HeaderiView.jsp. Just add the given JS code at the end of the page.

      Regards,
      Santhosh

      Author's profile photo Former Member
      Former Member
      Hi Santhosh,

      I am confused at the part on customtimeout.js and HeaderView.jsp.

      1.  What do you add into HeaderView.jsp?
      2.  Do you create a new js file call customtimeout.js and include the script into HeaderView.jsp? How do you do it?

      mike

      Author's profile photo Former Member
      Former Member
      Hi Santhosh,

      I am new at this. I don't understand about the part on customtimeout.js and headeriview.jsp.

      1. I got an error when I opened customtimeout.js by double clicking it:
      line: 14
      char: 7
      Error: Expected identifier, string or number
      Code: 800A0404
      Source: Microsoft JScript compilation error

      2. Besides adding the below code at the end of headeriview.jsp, what else do I need to include in headeriview.jsp relative to customtimeout.js?

      var timeout_h = customTimeoutHandler(10, 15);
      timeout_h.initialize();
      function pop() { timeout_h.updateTimer(); }
      EPCM.subscribeEvent("urn:com.sapportals:navigation", "Navigate", pop);
      //EPCM.subscribeEvent("urn:com.foo.bar.myapp", "myEvent", pop);

      Thanks,
      Ben

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,

      Sorry for the delayed response as I was not getting any updates regarding this post.

      The solution for your issue is updated in the above thread.

      Regards,
      Santhosh

      Author's profile photo Former Member
      Former Member
      Hi,

      In the customtimeout.js the line:

      EventID = window.showModalDialog("IEDialog.jsp","Dialog","dialogWidth:500px;dialogHeight:130px;toolbar:no;directories:no;status:no;menubar:no;scrollbars:no;resizable:no;modal:yes");

      presents a popup with a runtime error as you don't seem to be able to link directly to a jsp page. Please correct me if I'm wrong!?

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,

      If you can notice the code, the modal dialog window sends back the data to the parent page through Event Id.

      if(EventID != null && EventID == 'C')
      { timeout_h.updateTimer();
      timeout_h._refreshPage();}

      Now notice Dialog page code.
      function callBack(EventID) {
      window.returnValue = EventID;
      self.close();
      }

      The values are explicitly sent back for further action. Hope you understood this now.

      Regards,
      Santhosh

      Author's profile photo Former Member
      Former Member

      Hi,<br/><br/>Thanks for the reply. I think you misunderstood my question. I have included the customtimeout.js in HeaderIview.jsp using:<br/><br/><% String jsresourcepath = componentRequest.getWebResourcePath()+"/scripts/customtimeout.js"; %><br/><script type="text/javascript" src="<%=jsresourcepath%>"></script><br/><br/>The timeout works as expected and I get a popup with a portal error rather than the IEDialog.jsp. I believe its because the line in my 1st post doesn't have a context when trying to find IEDialog.jsp. Can you advise?

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,
      Sorry for the delayed response as I was not getting any updates reagrding this post.

      For your query, mention the complete path of the JSP page instead of IEDialog.JSP in your code.

      Ex: "/irj/portalapps/com.sap.portal.masthead/scripts/IEDialog.jsp", ....
      or
      "/irj/portalapps/com.sap.portal.masthead/PORTAL-INF/jsp/IEDialog.jsp", ....

      Refer, the code snippet again.

      Regards,
      Santhosh

      Author's profile photo Former Member
      Former Member
      This is fine if you navigate through tabs and the timeout resets the inactive time but if you are working within a web dynpro application or in KM, the timeout kicks in and logs you off.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      This post is a workaround for substituting a lack of standard functionality & not a flaw. For managing Webdynpro timers, there are standard timeout configuration parameters in configtool. To manage this at the application level, try using WebDynpro handlers along with EPCM listeners. I am sure there are other listeners for KM apps too.
      Author's profile photo Former Member
      Former Member
      i followed the steps given by you.i created a new par file with all modifications as you have mentioned.now trying to create an iview,but now iam confused with which component do i need to create the iview.there are some 6 components.can u please guide me on creating the iview,assigning to the page and so on.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,
      Sorry for the delayed response as I was not getting any updates regarding this post.

      Instead of creating a new PAR, you should do the above mentioned modifications in the standard Masthead PAR file to achieve this functionality.

      Regards,
      Santhosh

      Author's profile photo Bishnu Priya Sahoo
      Bishnu Priya Sahoo
      The IEDialog.jsp is not found when invoked,so getting an 404 error wkindow insteadof the pop up.

      I have kept the customtimeout.js under the dist/scripts folder and the jsp is in PORTAL-INF/jsp folder.Please let me know if there is anything i need to change.Its a bit urgent ,looking forward to you response

      Regards
      Priya

      Author's profile photo Abhi S
      Abhi S
      Hi Ria,

      I am also facing the same problem. Did you get any solution?

      Regards
      abhinav

      Author's profile photo Former Member
      Former Member
      I'm getting the same error: "The IEDialog.jsp is not found when invoked,so getting an 404 error wkindow insteadof the pop up."  Is there a resolution to this issue?
      Author's profile photo Former Member
      Former Member
      Even i am getting the same error. Can you help on this.. I am struck with on this
      Author's profile photo Former Member
      Former Member
      Hi venkata Supriya,

      i got the solutions. provide your mail id.. i will send updated code..

      Regards,
      VENU

      Author's profile photo Former Member
      Former Member
      Author's profile photo Former Member
      Former Member
      Hi Venu,

      Kindly reply me with the code, I am majorily struck with this.

      Supriya.

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      The Solution is updated in the above thread.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Eddie,

      Mention the complete path of the JSP page instead of IEDialog.JSP.

      Ex: "/irj/portalapps/com.sap.portal.masthead/scripts/IEDialog.jsp", ....
      or
      "/irj/portalapps/com.sap.portal.masthead/PORTAL-INF/jsp/IEDialog.jsp", ....

      Refer, the code snippet again.

      Regards,
      Santhosh

      Author's profile photo Prasanna Kumar
      Prasanna Kumar
      Did you resolve the issue . Kindly let me know how this is solved . Even I am facing the same problem
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Priya,

      Depending on where the JSP's are created, mention the corresponding parent folder by giving the complete path of the JSP page instead of IEDialog.JSP.

      Ex: "/irj/portalapps/com.sap.portal.masthead/scripts/IEDialog.jsp", ....
      or
      "/irj/portalapps/com.sap.portal.masthead/PORTAL-INF/jsp/IEDialog.jsp", ....

      Refer, the code snippet again.

      Regards,
      Santhosh

      Author's profile photo Former Member
      Former Member
      Hi santhosh,

      I have mentioned each and every thing through this blog. but i didn't get dailog window. i am getting Error on page at bottom of the browser.
       

      Webpage error details

      User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; CMNTDF; .NET4.0C; .NET4.0E)
      Timestamp: Thu, 7 Apr 2011 11:42:16 UTC

      Message: Expected identifier, string or number
      Line: 14
      Char: 7
      Code: 0
      URI: http://..../irj/portalapps/com.abb.timeout/scripts/customtimeout.js

      Message: Object expected
      Line: 501
      Char: 1
      Code: 0

      please suggest ASAP.

      Regards,
      VENU

      Author's profile photo Prasanna Kumar
      Prasanna Kumar
      Hi Santosh/Venu,

      Even I am getting the same error. Any solution for the same. thanks in advance

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      I have updated the solution in the above thread.
      Author's profile photo Prasanna Kumar
      Prasanna Kumar
      Hi Santosh .

      I am trying to incorporate your code in AFP Masthead.
      As soon as I log into portal I get  script error
      Message: Object doesn't support this property or method
      Line: 130
      Char: 1
      Code: 0
      URI: http://camhrd01.test.com:52000/irj/portalapps/com.test.portal.navigation.afp.masthead.timeout/javascript/customtimeout.js

      The script error which it points to “ logoff() ;” method in customtimeout.js.

      After running the script in few min, IEDialog.jsp page opens with a script error
      " black is undefined in line 28"

      Again after running the script with errors and clicking Logoff button I get the below error

      Webpage error details
      User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; GTB7.0; xs-BQhVyaEXOFs;ksVaLy; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
      Timestamp: Fri, 29 Apr 2011 18:34:20 UTC

      Message: Object doesn't support this property or method
      Line: 130
      Char: 1
      Code: 0
      URI: http://camhrd01.test.com:52000/irj/portalapps/com.test.portal.navigation.afp.masthead.timeout/javascript/customtimeout.js

      which points to method "logoff()”; in customtimeout.js ".

      The LogoffMessage.jsp opens stating its comments.

      But the portal is not closed or getting timed out in any of the about occurance. Only the JSPs  are opening.Kindly suggest so that it would be of greatest help. 

      Thanks in Advance.

      Author's profile photo Former Member
      Former Member
      Prasanna,

      I found an extra curley bracket at the end of the script.  When I took it out, it started working.  How did you add the "IEDialog.jsp" page to the par project?  The ide will not let me add a jsp, won't let me select a folder.  I can add a jsp in other projects.

      Thanks,

      Eddie

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hello All,

      I believe, there were typo errors which might have happened while I had reposted the code snippets along with some improvements in the application for multiple browser support. I have corrected the same & it should work now.

      If you come across any other typo errors, please notify the same as I had difficulty posting the snippets through this tool.

      Regards,
      Santhosh