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.
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.
IPortalComponentURI componentURI = request.createPortalComponentURI();
Set the name of the component. In the example below, the link is to the portal component myApplication.myComponent .
componentURI.setContextName("myApplication" + "." + "myComponent");
Set the request event, if necessary.
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.
componentURI.setTargetNode(request.getNode());
Set the mode, if necessary.
componentURI.setNodeMode(NodeMode.EDIT_MODE);
Create the URL string with the following:
componentURI.toString();