XPages - Open document in new tab with xp:openPage

3.1k Views Asked by At

I have this piece of code on my system, inside a xp:viewColumn:

<xp:eventHandler event="onclick" submit="true"refreshMode="complete">
    <xp:this.action>
        <xp:actionGroup>
            <xp:executeScript>
                <xp:this.script><!CDATA[#javascript:sessionScope.retornarPara=view.getPageName()}]]>
                </xp:this.script>
            </xp:executeScript>
            <xp:openPage target="openDocument" documentId="#javascript:entry.getDocument().getUniversalID()}">
                <xp:this.name>
                   <![CDATA[#{javascript:return "/xsp_arma.xsp"}]]>
                </xp:this.name>
            </xp:openPage>
        </xp:actionGroup>
    </xp:this.action>
</xp:eventHandler>

I need that the page opened by the xp:openPage be in a new tab. Is that possible? Do I need to use other type of code to do that?

Thanks.

2

There are 2 best solutions below

1
On

Instead of the simple action you can use ssjs

With the following url you can open a specified document:

application.nsf/xpage.xsp?action=openDocument&documentId=DOCUMENT_ID

var path = facesContext.getExternalContext().getRequest().getContextPath();

var xpage = "byTag.xsp"

var fullpath = path + "/" + xpage;

var documentID = "**"


var url = fullpath + "?action=openDocument&documentId="+ documentID


view.postScript("window.open('" + url + "')")

First you'll get the path of your current database then you can specify the xpage which will show the document and then youl can pass the documentID like #javascript:entry.getDocument().getUniversalID()}

With a call of csjs you can open the page in a new tab

0
On

If this event handler is inside a xp:link you can set the target of the link in all properties: enter image description here