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
Never hardcode URLs. Always use the API to create the URLs.
Create a IPortalComponentURI object from the request object. This object is a helper class in creating the URL.
Syntax
IPortalComponentURI componentURI = request.createPortalComponentURI();
Set the name of the component. In the example below, the link is to the portal component myApplication.myComponent.
Syntax
componentURI.setContextName("myApplication" + "." + "myComponent");
Set the request event, if necessary.
Syntax
IPortalRequestEvent myRequestEvent = request.createRequestEvent("myEvent");
componentURI.setPortalRequestEvent(myRequestEvent);
You can add parameters in the request by adding an IPortalRequestEventData object - which contains key-value pairs - to the IPortalRequestEvent object.
Set the target of the request event, if necessary. In the example below, the target is the current component.
Syntax
componentURI.setTargetNode(request.getNode());
Set the mode, if necessary.
Syntax
componentURI.setNodeMode(NodeMode.EDIT_MODE);
Create the URL string with the following:
Syntax
componentURI.toString();