Frantisek Kossuth
Frantisek Kossuth

Reputation: 3524

native Domino links and XPages

Users open documents by links in old format http://server/db.nsf/VIEW_UNID/DOC_UNID. The form has property set to open XPage instead.

Origin of these links is email notification generated by "universal agent". It simply sends link to document. It does not know, what form is associated with what XPage, therefore it generates universal links instead of "/page.xsp&documentId=...".

The problem: relative links computed at client do not work - < a href = "/page.xsp?params"> should be more effective - no roundtrip and easy to compute at page load. They evaluate to http://server/db.nsf/0/page.xsp?params, what ends with Error 404, naturaly.

XPage contains "help" section, what is another document with RT field containing text, images and links. And relative links in that RT field work when XPage is opened from another XPage - view (/page.xsp), but fail when redirected from notification link (/0/UNID).

Question: How to effectively reset browser's address bar to extended XPages format http://server/db.nsf/page.xsp?documentId=DOC_UNID after opening redirected documents/views by old fashioned URLs?

Upvotes: 0

Views: 3208

Answers (3)

Frantisek Kossuth
Frantisek Kossuth

Reputation: 3524

Main problem is in discrepancy of relative links on server side (evaluated in SSJS) and client side (evaluated by browser). I have solved my problem by simple redirect in case document is open by old fashioned link.

<?xml version="1.0" encoding="UTF-8"?>
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core">
        <xp:eventHandler event="onClientLoad" submit="false">
            <xp:this.script><![CDATA[var url = "#{javascript:context.getUrl()}";
    var l = window.location;
    if (url != l) {
        window.location.replace(url);
    }
    ]]></xp:this.script>
    </xp:eventHandler>
</xp:view>

Simply said, if open URL differs from internal URL (as resolved by XSP engine), browser redirects to correct URL. This solved many problems we had with inline images (image resource) and attachments.

Upvotes: 1

Sven Hasselbach
Sven Hasselbach

Reputation: 10485

Have you tried to set pageBaseUrl property in your XPages? This would help to repair the relativ links:

<xp:this.pageBaseUrl>
   <xp:baseUrl>
      <xp:this.href><![CDATA[#{javascript:"http://stackoverflow.com/"}]]></xp:this.href>
   </xp:baseUrl>
</xp:this.pageBaseUrl>

Another idea is to do a redirect in beforePageLoad-event in the XPage if the URL is in old fashioned style.

Upvotes: 0

pipalia
pipalia

Reputation: 911

Try "./page.xsp&params" or ../ if you want to go back to the root - I have noticed IBM do this in their coding as well. Hope this helps.

Upvotes: 0

Related Questions