1

I have to implement the following request, but all my tries failed:

If you click on a button/link in a XPage (XPiNC), a classic Notes-Document shall be created in another Notes Database. This new Notes document has to be open in a new client tab beside the tab with the XPage.

I’ve tried several ways with

FacesContext.getCurrentInstance().getExternalContext().redirect("notes://server/anotherdb/newdocumentunid?openDocument")

but none of them led to the desired result (There were 3 tabs opened or the XPage tab is empty).

Naveen
  • 6,786
  • 10
  • 37
  • 85

3 Answers3

2

Have you tried using window.open in client side javascript.

Add the code window.open("Notes://database/view/document?EditDocument")

that should work.

Fredrik Norling
  • 3,461
  • 17
  • 21
  • Thanks Fredrik, but then I have this problem: To get the unid of the new classic document I have to create/save this at first. So every time, the url "Notes://database/view/document?EditDocument" is computed, i.e., every time the XPage is loaded, a new classic document will be saved in the other database. – Rainer Lütkenhaus May 21 '13 at 12:09
  • You want a button that creates a document in another database and that document is then opened in a new tab correct? – Fredrik Norling May 21 '13 at 12:53
  • I have modified my answer, Sorry didn't see the answer by Knut – Fredrik Norling May 21 '13 at 15:49
  • Thank you for your help, Frederik. Knut's suggestion is the perfect solution for my problem. – Rainer Lütkenhaus May 22 '13 at 06:48
0

EDIT:

It is possible to execute CSJS from SSJS with view.postScript().

    <xp:button value="client" id="button3">
        <xp:eventHandler event="onclick" submit="true" refreshMode="partial" disableValidators="true">
            <xp:this.action><![CDATA[#{javascript:var url = myJavaClass.createNewDocumentAndReturnNotesUrl(); view.postScript("window.open('" + url + "')");}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>

CSJS function window.open(url) is executed from SSJS after creating document in other database and getting back the URL for the new document. This way, the code is only executed when button is clicked and new document opens in a new window.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Thanks Knut, but I have with this solution the same problem as mentioned above in my comment: To get the docid I has to save the new document at first. So every time my XPage is loaded and the url is computed a new document is created/saved in the other database without clicking any button. My code: ` <![CDATA[window.open('#{javascript:myJavaClass.createNewDocument();}')]]> ` The JavaClass method returns the computed url – Rainer Lütkenhaus May 21 '13 at 14:03
0

Actually, to create a document in the other database, you don't need to worry about what the document's UNID is. Just use this javascript:

window.open("Notes://database/form?CreateDocument")
David Navarre
  • 1,022
  • 10
  • 27