Show TOC

Background documentationGenerating Portal URLs Locate this document in the navigation structure

 

A problem can arise when the content includes navigation links to other content on the NetWeaver producer:

  • If the iView is displayed to a user on the consumer portal, the link must point to the proxy portlet.

  • If the iView is displayed to a user on the producer portal, the link must point to the source iView on the producer .

The underlying application has no way of knowing who is viewing the content, and cannot determine what type of link to provide. In addition, a link to an iView proxy is not a standard portal URL, and contains additional parameters.

URLs in Portal Applications

In order to create proper links, adhere to the following developer guidelines for creating portal URLs for navigation links:

  • Never hard-code portal URLs.

  • Only create URLs using the Portal Runtime API, as follows:

    1. For URLs for navigation links (such as for <a> tags), use the following code, where myApplication.myComponent is the fully qualified name of a portal component:

      Syntax Syntax

      1. IPortalComponentURI componentURI = request.createPortalComponentURI();
        componentURI.setContextName("myApplication.myComponent");
        myUrl = componentURI.toString();
        
      End of the code.

      Instead of a fully qualified component name, you can also specify a PCD address of an iView.

    2. For URLs to resources (such as for <img> tags), use the following code, where images/myImage.gif is the path to the image file:

      Syntax Syntax

      1. IResource myResource = request
            .getResource(IResource.IMAGE,"images/myImage.gif");
        String imageURL = myResource.getResourceInformation()
            .getURL(componentRequest)
        
      End of the code.

      A resource, such as a JSP or JavaScript file, also can be added directly to the response, as follows:

      Syntax Syntax

      1. IResource myResource = request
            .getResource(IResource.JSP,"jsp/myJSP.jsp");
        response.include(request, myResource);
        
      End of the code.
  • Do not make any assumptions about the URL produced by the portal API.

    For example, if you need to add URL parameters, don't assume that there are no URL parameters already. Check whether the URL already has a question mark (?) for indicating the start of URL parameters. If there is one, do not add another when appending your URL parameters.

  • Do not use the following methods for navigating:

    • Client-side eventing EPCM.doNavigate() method.

    • <navNodeAnchor> tag of the navigation JSP tag library.

URLs in Portlets

When creating URLs from within portlets, make sure to use the portlet API, as described in the Java Specification Request (JSR) 168 / JSR 286.

For more information about the specification, see http://www.jcp.org.