-
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.