Skip to main content

Open the Navigation Link (defined in navigation model) in a New Window

A navigation link can be opened in the current window or a new window. By default it would open ni the current window. There are a number of the predefined URL attribute for a navigational resource. For a complete list of the URL attributes, please refer to here. One of the attribute is "Target". As per the description,  it's the location on the container page where the resource is displayed when it is selected, either in the same browser window (_self), a new window (_blank), or a popup (_popup), or any other location supported by the navigation UI.

Is that it? Not really, if you have custom developed your navigation UI.

The "target" attribute is nothing special here, as it's just an attribute with a meaningful name. The navigation UI needs to specifically evaluate the attribute and handle it.

Here are the two steps to do:

1. apply a swticher on the navigation model node. If the target is "_blank", use the golink component.


<af:switcher id="pt_sw2" facetName="#{(empty node2.attributes['Target']) || (node2.attributes['Target'] == '_blank) ? 'command' : 'golink'}">


2. in the goLink facet, apply the target attribute to the golink's target property.

<f:facet name="golink">
  <af:goLink id="pt_gl2" text="#{node2.title}"
             destination="#{node2.goLinkPrettyUrl}"
             targetFrame="#{node2.attributes['Target']}"/>
</f:facet>


Now we see why the "target" attribute in the navigational resource is not special.

Comments