Welcome to the IBM Collaboration Solutions Community IQJam
UsernamePassword
Reset Password | Register
   
Home | Tags | Help
Where Would I Delete My Cookie? 
  • The following is all being used on the 8.5.2 Notes client.  It is being done so that help documents can be updated by administrative staff.
  • I have an xPage which contains a button entitled Help.  This button contains the following client side JavaScript:

var url = "Help_Display.xsp";
var form = '#{javascript:currentDocument.getItemValue("form")}';

var dialog = new dijit.Dialog({
 title: "Help",
 content: "<iframe src='" +
        url +
        "' height='90%' width='90%' frameborder='0' scrolling='auto'></iframe>",
         style: "width: 90%; height: 90%;"
});

setCookie('form', form, '1');

dialog.show();

  • The dijit.Dialog will actually open an xPage in the iframe and the reason I have set a cookie with the form name is so that the Document ID on the xPage will display the appropriate Help document for the current document. 
  • Here is the server side JavaScript calculating the Document ID on the xPage. 

var map = facesContext.getExternalContext().getRequestCookieMap();
var form = map.get("form");
if(form != null){
    if(@Contains(form.getValue(), "EmployerProfile")){
        @DbLookup(@DbName(), "AdminHelpMaint", "Employer Profile", 2);
    }
    else if(@Contains(form.getValue(), "StudentProfile")){
        @DbLookup(@DbName(), "AdminHelpMaint", "Student Profile", 2);
    }
}

  • Now where the problem arises, is that I need a place to delete the cookie, so that when the user goes to a document with another form and presses the Help button, the old cookie will be gone and just the newly-created cookie will remain.
  • I have tried not putting an expiry argument into the setCookie function, but that does nothing for me.
  • I have tried putting the following code into the xPage that displays the help document:

<xp:scriptBlock>
  <xp:this.value escape="false">
 <![CDATA[#{javascript:
   onunload=function(){var map = facesContext.getExternalContext().getRequestCookieMap();
var form = map.get("form");
if(form != null){
    form.setMaxAge(0);
    form.setValue(null);
}} }
  ]]>
  </xp:this.value>
 </xp:scriptBlock>

  • I have also tried to put the above function into just about every xPage event I could think of, but it always seems to delete the cookie too late.  And the onunload doesn't seem to run for the help xPage, but I'm thinking this is because it is closed by using the x at the top right of the dialog.

If anybody can please tell me where I would put the cookie deletion code, that would be wonderful!  And do feel free to critique or use any of this code if you find it useful.

Domino Development / XPages
Lenni Sauve - over 2 years ago |  |  | Viewed 333 times

There is 1 answer

0votes

One of our web team helped me with this!

 

Where I call the help document, I needed to move the set cookie up before calling the dijit.Dialog.  And then, after dialog.show(); I needed to add the following line:

setCookie('form', null, 0)

 

That did it! 

Lenni Sauve - over 2 years ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community

Latest Answers for Domino Development / XPages 

How to call LS agent in xpage
Vijay Kumar - 6 months ago
Multi-values in an xPage view panel column
Judy Kilpinen - 7 months ago
From CSJS refresh a panel dijit.TooltipDialog
daniele grillo - about 1 year ago
How to get value from Repeater Control.
Atul Saxena - about 1 year ago
doing a partial update "beforepageload"
jeroen somhorst - about 1 year ago
How to get value from Repeater Control.
jeroen somhorst - about 1 year ago
How to get value from Repeater Control.
Mervin Thomas - about 1 year ago
Where Would I Delete My Cookie?
Lenni Sauve - over 2 years ago
Query_String value empty with agent URL from xpage
Andy Cunliffe - over 2 years ago
textfield formatting
Ben Poole - over 2 years ago
File Upload/File Download using Managed Beans
Toby Samples - over 2 years ago
File Upload/File Download using Managed Beans
Andy Cunliffe - over 2 years ago

Experts for Domino Development / XPages

There are no experts to display