Show TOC

Procedure documentationCreating URLs to Components Locate this document in the navigation structure

 

You may want to create links between portal components by putting the URL of a portal component in a hyperlink tag (<a>). The Portal Runtime includes an API for creating URLs to portal components.

Note Note

Never hardcode URLs. Always use the API to create the URLs.

End of the note.

Procedure

  1. Create a IPortalComponentURI object from the request object. This object is a helper class in creating the URL.

    Syntax Syntax

    1. IPortalComponentURI componentURI = request.createPortalComponentURI();
    End of the code.
  2. Set the name of the component. In the example below, the link is to the portal component myApplication.myComponent.

    Syntax Syntax

    1. componentURI.setContextName("myApplication" + "." + "myComponent");
    End of the code.
  3. Set the request event, if necessary.

    Syntax Syntax

    1. IPortalRequestEvent myRequestEvent = request.createRequestEvent("myEvent");
    2. componentURI.setPortalRequestEvent(myRequestEvent);
    End of the code.

    You can add parameters in the request by adding an IPortalRequestEventData object - which contains key-value pairs - to the IPortalRequestEvent object.

  4. Set the target of the request event, if necessary. In the example below, the target is the current component.

    Syntax Syntax

    1. componentURI.setTargetNode(request.getNode());
    End of the code.
  5. Set the mode, if necessary.

    Syntax Syntax

    1. componentURI.setNodeMode(NodeMode.EDIT_MODE);
    End of the code.
  6. Create the URL string with the following:

    Syntax Syntax

    1. componentURI.toString();
    End of the code.