David Marko
David Marko

Reputation: 2519

How to create link to another database using link control?

How to create link to another database using link control? I thought that I simply start URL with slash but it doesnt work as xpages prepends path to current database to this link and I'm getting wrong link as this one: /app/projects.nsf/database.nsf/page.xsp

<xp:link escape="true" text="Link" id="link1" value="/database.nsf/page.xsp">   
</xp:link>

I know that I can create absolute link starting with http:// but I would like to avoid this ...

Upvotes: 1

Views: 695

Answers (3)

Brian Sherwood
Brian Sherwood

Reputation: 53

To build on Sven's answer, I computed the URL, and set the target to be a new tab. So my xp:text element is:

<xp:text id="label4" escape="true"
    styleClass="btn btn-default" value="Open Fastworks Document"
        tagName="a">
    <xp:this.attrs>
        <xp:attr name="href">
        <xp:this.value><![CDATA[#{javascript:var sUNID = document1.getItemValueString("FWUNID");
var sNSF = document1.getItemValueString("FWNSF").replace("\\","/");
//sys_all/A4DC4CFDA12A1A4E80257F48003DD8F9?OpenDocument
"/"+sNSF + "/sys_all/"+sUNID;}]]></xp:this.value>
        </xp:attr>
        <xp:attr name="target"
                value="_blank">
        </xp:attr>
    </xp:this.attrs>
</xp:text>

This then produces HTML such as :

<a class="btn btn-default" id="view:_id1:_id2:callback2:label4" href="/Fastworks/Version52m/Accident.nsf/sys_all/31F7D581D23BCFE580257FA1002E3B43" target="_blank">Open Fastworks Document</a>

Upvotes: 0

Sven Hasselbach
Sven Hasselbach

Reputation: 10485

You can use the xp:text element and convert it to an anchor:

<xp:text escape="true" id="link1" tagName="a" value="Link">
   <xp:this.attrs>
      <xp:attr name="href" value="/database.nsf/page.xsp"></xp:attr>
   </xp:this.attrs>
</xp:text>

Or add the link as Passthrough Tag.

Upvotes: 1

Michael Ruhnau
Michael Ruhnau

Reputation: 1399

If the database is in the same sub-directory on the server, you can use ../xxx.nsf For every sub-folder you want to go back, you can prepend a ../

Example in your case:

<xp:link escape="true" text="Link" id="link1" value="../database.nsf/page.xsp">
</xp:link>

If the database would be one folder above the current databases' folder you can use this:

<xp:link escape="true" text="Link" id="link1" value="../../database.nsf/page.xsp">
</xp:link>

Hope that helps. Michael

Upvotes: 1

Related Questions