-
1. Re: links from portlet content to another portal page
belcar Oct 1, 2009 3:01 AM (in response to hamptont)The reference guide has a topic about this: "13.9.3. Link to other pages."
// Get the ParentNode. Since we are inside a Window, the Parent is the Page PortalNode thisNode = req.getPortalNode().getParent(); // Get the Node in the Portal hierarchy tree known as "../default" PortalNode linkToNode = thisNode.resolve("../default"); // Create a RenderURL to the "../default" Page Node PortalNodeURL pageURL = resp.createRenderURL(linkToNode); // Output the Node's name and URL for users Samples 149 html.append("Page: " + linkToNode.getName() + " -> "); html.append("<a href=\"" + pageURL.toString() + "\">" + linkToNode.getName() + "</a>");
-
2. Re: links from portlet content to another portal page
hamptont Oct 1, 2009 1:01 PM (in response to hamptont)I tried the code from the reference guide but I can't get it working correctly. The following is a test portlet jsp fragment that I'm working with.
The portal page structure is like thispageA pageB pageC
The jsp fragment below is for a portlet that is on page B and is trying to resolve the pageURL to pageC which is a sub-page of pageB<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> <%@ page isELIgnored="false" %> <%@ page import="org.jboss.portlet.JBossRenderRequest" %> <%@ page import="org.jboss.portlet.JBossRenderResponse" %> <%@ page import="org.jboss.portal.api.node.PortalNode" %> <%@ page import="org.jboss.portal.api.node.PortalNodeURL" %> <portlet:defineObjects/> <% JBossRenderRequest req = new JBossRenderRequest(renderRequest); JBossRenderResponse resp = new JBossRenderResponse(renderResponse); PortalNode thisNode = null; PortalNode linkToNode = null; PortalNodeURL pageURL = null; thisNode = req.getPortalNode().getParent(); if (thisNode != null) linkToNode = thisNode.resolve("pageC"); if (linkToNode != null) pageURL = resp.createRenderURL(linkToNode); %> <p> thisNode = <% if (thisNode != null) { %> <%= thisNode.getName() %> <% } else { %> null <% } %> </p> <p> linkToNode = <% if (linkToNode != null) { %> <%= linkToNode.getName() %> <% } else { %> null <% } %> </p> <p> pageURL = <% if (pageURL != null) { %> <%= pageURL.toString() %> <% } else { %> null <% } %> </p>
This example also produces a bizarre and very long error on the call to thisNode.resolve(). I am not sure that I'm getting the references to JBossRenderRequest & JBossRenderResponse correctly, but the example in the reference guide does not say what the correct way is to get these objects.12:46:07,397 ERROR [PortalPermissionCollection] Permission check against the repository failed org.hibernate.HibernateException: Unable to locate current JTA transaction .........
I'm not sure what to the correct way to do this is but I'm pretty sure I did it wrong :) -
3. Re: links from portlet content to another portal page
apemberton Oct 5, 2009 12:45 PM (in response to hamptont)The message you're getting may be resolved by configuring your jboss-portlet.xml with a transaction attribute, otherwise your two portlets won't be able to generate URLs to eachother:
<portlet-name>YourPortlet</portlet-name>
<trans-attribute>Required</trans-attribute>
The the appropriate reference guide for info on the jboss-portlet.xml descriptor: http://docs.jboss.org/jbportal/v2.6.4/referenceGuide/html/jbossPortletDTD.html -
4. Re: links from portlet content to another portal page
hamptont Oct 7, 2009 5:54 PM (in response to hamptont)Thanks apemberton,
That was the trick.
This is a pretty onerous way to create a simple link to a page. Is there a simpler way ?
Thanks.