Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
What's the XPages version of @Command([FileCloseWindow]) for the Notes client? 
So, in the Notes client, when user double clicks on a document in a view, I've programmed it to open an XPage in a new tab.  (basically figuring out the notes:// url and opening it).

So far so good.  But when they are done, I want to have the equivalent of @Command([FileSave]); @Command([FileCloseWindow])
 
How do I tell the XPage to close?  What's the equivalent of  @Command([FileCloseWindow])?
 
Within the client, I've tried window.close in the Notes client with the following XPage code:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:button value="Test Close" id="button1">
        <xp:eventHandler event="onclick" submit="false">
            <xp:this.script><![CDATA[window.close();]]></xp:this.script>
        </xp:eventHandler>
    </xp:button>
</xp:view>

But it doesn't work.  Anyone have any ideas?
Domino Development / XPages
Tagged
John Smart - about 1 year ago |  |  | Viewed 1137 times

There are 8 answers

1votes
Marked as correct on1/27/12 6:19 AM
Firstly, @Commands() won't work in XPages, even using session.evaluate()
 
However, we're looking to address both actions, opening a window in a new tab and closing the window, for XPiNC in 852. 
 
To open a new window in XPiNC, you will use the 'target' property, setting it to _blank.
 
To close, we're looking to support window.close()
 
hope this helps. 
p. 
 
 


Paul Hannan - about 1 year 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


0votes
Backtracking just slightly here on the link with the blank target, we're currently looking at a solution, window.close(), that won't work with this type of link in XPiNC.
 
We're looking at getting this working with window.open(). 
 
hope this helps (again)
 
p. 
 
ps: it would be great to be allowed to edit your own answers on IQJam (Matt) ;-)
 
 


Paul Hannan - about 1 year 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


0votes
Thanks for the info, Paul.  Good to know that IBM knows it's missing.
 
Until IBM supports window.close() in the client, does anyone else have a workaround?


John Smart - about 1 year 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


0votes
I heard that this was going to be available in 8.5.2.
 
I just tried it and got an error: "[ReferenceError] 'window' not found". 
 
Does anyone know when support for window.close will be added?
 
I need it in order for my newest app to function properly in the Notes client.  In a web browser, my cross-db links and redirects all open in the same tab, but cross-db links and redirects always open in a new tab in the Notes client.  If there's a way to force an xpage from a different database to open in the same tab in the Notes client, then that would be even better.


Bill Hanson - about 1 year 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


0votes
Hi Bill,
 
I am creating an application that spans across multiple NSF applications and multiple Xpages in each application. I am providing a sidebar with xp:link controls that redirects to all these xPages.
 
Question is:
 
1. How to provide the links such that they work correctly for both Notes client and Browser? "Open Page" option on xp:link control only allows to enter XPages in the same application. 
 
2. If I provide "Open Page" option, it still opens the page in different tab on notes client. How this can be changed? 
 


CHINMAY ASARAWALA - about 1 year 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


0votes

Hi Chinmay,
 
If you set the 'Link Type' to computed, you can use any URL.

If the link is external to the current application database, then it will always open in a new tab in the Notes client.  I have not found a workaround for this.



Bill Hanson - about 1 year 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


0votes
Thanks Bill. I have used computed and it is working correctly. But I had to do a lot of processing like for notes client, the URL should have "notes://<server>/<db>/<xpage>?OpenXPage" but for web browser I have "http:" //<server>/<db>/<xpage>. So this is just a workaround and domino directly does not provide any facility to do this. Anyway. It still works.
 
Regarding opening in the same tab, I have seen new option "Window behaviour" in 8.5.2 where I can specify whether to open in new tab or in the same tab even when the xPage is in the same application but that still doesn't work.  


CHINMAY ASARAWALA - about 1 year 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


0votes

I've built a library for my xPage apps that includes functions like 'gotoPage', 'returnToPage', 'callToPage', and 'returnFromCall'.  These 4 functions form the basis of my navigation engine and work in all clients.  They all rely on a fifth function named 'getUrl' that does most of the work.  I've posted the 'getUrl' function code below for reference.  It was ripped from my library, so there is some dependant code missing.

 var MIS_CLIENT_IS_NOTES:boolean = (@ClientType() == 'Notes');
 var MIS_CURRENT_PROTOCOL:string = MIS_CLIENT_IS_NOTES ? 'notes' : 'http';

 getUrl: function(page:string, target, setReturnUrl:boolean, setSaveUrl:boolean, readOnly:boolean, parameters:java.util.HashMap, forceExternal:boolean){
  if (typeof setReturnUrl === 'undefined') setReturnUrl = false;
  if (typeof setSaveUrl === 'undefined') setSaveUrl = false;
  if (typeof readOnly === 'undefined') readOnly = false;
  if (typeof parameters === 'undefined') parameters = null;
  if (typeof forceExternal === 'undefined') forceExternal = false;
  // handle custom @Functions
  var fn:Array = MisUtil.parseLotusFunction(page);
  if (fn != null){
   switch(fn[0]){ // custom @Function name
    case 'ExternalPage': // @ExternalPage("SettingsFieldName", "pageName.xsp")
     target = MisApp.openSettingsDb(fn[1]);
     var pn:string = fn[2];
     if (pn.endsWithIgnoreCase('.xsp')){
      page = pn;
     }else{
      page = MisApp.getSetting(pn);
     }
     break;
    default:
     exception('MisApp.getUrl: Invalid custom @Formula: ' + fn[0] + '!');
   }
  }
  // determine context
  var targetDoc:NotesDocument = null;
  var targetDb:NotesDatabase = null;
  switch(typeof target){
   case 'lotus.domino.local.Document':
    targetDoc = target;
    break;
   case 'NotesXspDocument':
   case 'com.ibm.xsp.model.domino.wrapped.DominoDocument':
    targetDoc = target.getDocument();
    break;
   case 'lotus.domino.local.Database':
   case 'com.ibm.domino.xsp.module.nsf.NSFComponentModule$XPagesDatabase':
    targetDb = target;
    break;
   case 'NotesXspViewEntry':
    targetDoc = target.getDocument();
    break;
   case 'string':
    if (target.length() == 32){
     targetDoc = database.getDocumentByUNID(target);
    }else{
     targetDoc = database.getDocumentByID(target);
    }
    break;
   case 'undefined':
    break;
   default:
    exception('MisApp.getUrl - target type is not recognized: [' + typeof target + ']!');
  }
  if (targetDoc != null) targetDb = targetDoc.getParentDatabase();
  if (targetDb == null) targetDb = session.getCurrentDatabase();
  // construct url
  var isExternal:boolean = page.startsWithIgnoreCase('http://') || page.startsWithIgnoreCase('notes://');
  var url:Array = [];
  if ((!isExternal && !MisUtil.dbIsCurrent(targetDb)) || forceExternal){
   url.push(MIS_CURRENT_PROTOCOL);
   url.push('://');
   url.push(MisUtil.getUrlHost(targetDb));
   url.push('/');
   url.push(MisUtil.getUrlFilePath(targetDb));
   url.push('/');
   isExternal = true;
  }else{
   if (page.endsWithIgnoreCase('.xsp') && !page.startsWith('/')) url.push('/');
  }
  url.push(page);
  if (page.endsWithIgnoreCase('.xsp')) url.push('?OpenXPage');
  // add document id
  if (targetDoc != null){
   url.push('&documentId=');
   url.push(targetDoc.getNoteID());
   url.push('&action=');
   if (readOnly){
    url.push('openDocument');
   }else{
    url.push('editDocument');
   }
  }
  // add return URLs
  var returnUrl:string = '';
  if (setReturnUrl || setSaveUrl) returnUrl = MisApp.getUrl(MisApp.getPageName(), targetDoc, false, false, false, null, isExternal);
  if (setReturnUrl){
   url.push('&returnUrl=');
   url.push(urlEncode(returnUrl));
  }
  if (setSaveUrl){
   url.push('&saveUrl=');
   url.push(urlEncode(returnUrl));
  }
  // add custom parameters
  if (parameters != null){
   for (paramName in parameters.keySet()){
    url.push('&');
    url.push(paramName);
    url.push('=');
    url.push(parameters.get(paramName));
   }
  }
  return url.join('');
 }



Bill Hanson - about 1 year 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