1
votes

i'm currently working on a function (started after Buttonclick) to print a document in Lotus Notes (IBM Domino Designer 9.0 Social Edition Release 9.0). I have a custom control which creates a new document to the database. After saving the document its opened in read-only-Mode. There you have a button which will redirect you to a new window where the same contents are displayed without any layouts and something else (just the Text). Now its possible to print the page with Ctrl+P. There are two differen xPages for that.

  1. Distribution.xsp
  2. DistributionPrint.xsp

First of all i'm using

path = facesContext.getExternalContext().getRequest().getRequestURL(); 

to get the current page URL. After that there is an option to replace the current Page of the path (Distribution.xsp) into DistributionPrint.xsp.

var replacePage = @RightBack(path, "/");
path = @ReplaceSubstring(path, replacePage, "DistributionPrint.xsp");

When im testing it the replacement successfully worked. After that i'm bulding a new URL for the specific document to open with the new path. Finally everything is placed into the view.postScript method:

var docid = docApplication.getDocument().getUniversalID();
view.postScript("window.open('"+path.toString() + "?documentId=" + docid + "&action=openDocument"+"')")

Now my Problem starts. At 99% of my trys the new window is opened like i said the programm to do. But there are some kind of documents where i click on the button and he doesn't open a new window and trys to open the old Distribution.xsp url. I already tested out the path he wants to open at these kind of documents by using the debugtoolbar. The result of the button click returns the completly correct URL which should be opened. I can also copy that url and paste it manually into my browser => it works! But if i want to open that URL by a buttonclick and viewPostScript nothing happens.

Has anybody expierenced the same problem like me? Maybe one of you can help me through that problem. Its really annoying that everything works finde at 99% of my documents but at some documents it doesn't work although the given url is 100 percent correct.

Thanks for everyones help!

4
Debug result of GET/POST request of that partial refresh - can you see the postscript code at the end of returned HTML? - Frantisek Kossuth

4 Answers

2
votes

Try adding you code into a javascript function on the page and call that function from your view.postscript code Or as Panu suggested add it to onCompete code

0
votes

If the URL is correct then it sounds like a problem with view.postScript. Try with <xp:this.onComplete>.

Other things to try:

  • Use var w = window.open(... Plain window.open may change the URL of current window.
  • Double check the URL with an alert();
0
votes

You might be barking up the completely wrong tree. Did you try, instead of creating a second page for printing, create a second CSS stylesheet?

Using @Media Print you can tell the browser to use that stylesheet for printing. There you set all navigational elements to display : none and they won't print.

Removes the need to maintain a separate XPage for the printing stuff.

0
votes

Thank you everyone for your suggestions. The solution of Fredrik Norling worked for me. I placed the Code into a function and called it at the buttonclick. Now every page is opened as expected. Thank you very much for the help!