Search code examples
xpageslotus-notesxpinc

How to open a classical Notes document in a new client tab, triggered by a XPage


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


Solution

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