Question

I have found a few similar questions to this in stackoverflow but nothing exactly matches. I am attempting to amend an Xpages project where the search results are shown in a Dynamic View Panel. The first column of the search results is a link that opens the record in the same page. What I want to do is have this link open the record in a seperate page. It is the "Dynamic" part of the view that is confusing I think as there is no "Column Name" or "Column View" to add in a window.open or a target="_blank" that I can see. How would I go about this please?

The relevant section of the XPage only has the following;

<xp:panel id="maincontentpanel">
    <xe:dynamicViewPanel rows="30" id="dynamicViewPanel1" width="100%">
      <xe:this.data>
         <xp:dominoView viewName="(keywordsUser)" var="view">
         </xp:dominoView>
      </xe:this.data>
   </xe:dynamicViewPanel>
</xp:panel>

When viewing the source in HTML the clickable column shows the following;

<tr>
    <td class="xspColumnViewStart">
        <a id="view:_id1:cc4cconeuilayout:OneUIMainAreaCallback:dynamicViewPanel1:0:_id6:_internalColumnLink"
           href="*routetoourrecord*";action=editDocument"
           class="xspLinkViewColumn">2014</a>
    </td>
Was it helpful?

Solution

Dynamic View Panel has a property "target" in All Properties where you can select "_blank". This should add the attribute target="_blank" to the links in first column. But, unfortunately, this works in Notes client only.

So, there is no property we just can set. Luckily, rendered links have an own class "xspLinkViewColumn" (see your source HTML example). With dojo.query we can get all elements with this class and add the target attribute on client side.

Just add following event code to your XPage:

<xp:eventHandler
    event="onClientLoad"
    submit="false">
    <xp:this.script><![CDATA[
         dojo.query(".xspLinkViewColumn").attr("target", "_blank");
    ]]></xp:this.script>
</xp:eventHandler>

All links will get the attribute target="_blank" this way and documents will be opened in a new browser tab.

OTHER TIPS

Just to let know the code does not to work with the Bootstrap theme.

Instead you can use

dojo.query('[id$="_internalColumnLink"]').attr("target", "_blank"); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top