Return-Path: Delivered-To: apmail-jakarta-jetspeed-dev-archive@apache.org Received: (qmail 56558 invoked from network); 5 Mar 2002 12:26:38 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 5 Mar 2002 12:26:38 -0000 Received: (qmail 14599 invoked by uid 97); 5 Mar 2002 12:26:35 -0000 Delivered-To: qmlist-jakarta-archive-jetspeed-dev@jakarta.apache.org Received: (qmail 14559 invoked by uid 97); 5 Mar 2002 12:26:34 -0000 Mailing-List: contact jetspeed-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jetspeed Developers List" Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@jakarta.apache.org Received: (qmail 14548 invoked by uid 97); 5 Mar 2002 12:26:34 -0000 Date: 5 Mar 2002 12:26:33 -0000 Message-ID: <20020305122633.88632.qmail@icarus.apache.org> From: sgala@apache.org To: jakarta-jetspeed-cvs@apache.org Subject: cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedTemplateLink.java PortletTemplateLink.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N sgala 02/03/05 04:26:33 Modified: src/java/org/apache/jetspeed/portal/portlets VelocityPortlet.java src/java/org/apache/jetspeed/util/template JetspeedTemplateLink.java PortletTemplateLink.java Log: Change the mechanism to have jlink in the toolbox. Instead of instantiating a new one for each request, leave the work to turbine, and setPortlet() of the right one in the rendering code. This deprecates the whole PortletTemplateLink class (I should have removed it, but...) as now JetspeedTemplateLink is able to deliver context sensitive links for Panes. I hope I won't break anything. Revision Changes Path 1.12 +5 -2 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java Index: VelocityPortlet.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- VelocityPortlet.java 28 Jan 2002 11:25:50 -0000 1.11 +++ VelocityPortlet.java 5 Mar 2002 12:26:33 -0000 1.12 @@ -65,7 +65,7 @@ import org.apache.jetspeed.portal.portlets.AbstractPortlet; import org.apache.jetspeed.portal.PortletException; import org.apache.jetspeed.services.TemplateLocator; -import org.apache.jetspeed.util.template.PortletTemplateLink; +import org.apache.jetspeed.util.template.JetspeedTemplateLink; import org.apache.jetspeed.services.JetspeedSecurity; import org.apache.jetspeed.services.security.JetspeedSecurityService; @@ -119,7 +119,10 @@ // Put the request and session based contexts TurbinePull.populateContext(context, rundata); - context.put( "jlink", new PortletTemplateLink(rundata,this) ); + //We need to initialize the jlink tool with ourselves to + // enable links between portlets. + JetspeedTemplateLink jlink = (JetspeedTemplateLink) context.get( "jlink" ); + jlink.setPortlet( this ); String actionName = getPortletConfig().getInitParameter("action"); 1.6 +88 -15 jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateLink.java Index: JetspeedTemplateLink.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateLink.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JetspeedTemplateLink.java 22 Jul 2001 20:31:11 -0000 1.5 +++ JetspeedTemplateLink.java 5 Mar 2002 12:26:33 -0000 1.6 @@ -60,16 +60,25 @@ import org.apache.turbine.util.template.TemplateLink; import org.apache.turbine.services.pull.ApplicationTool; +import org.apache.jetspeed.portal.Portlet; +import org.apache.jetspeed.portal.PortletController; +import org.apache.jetspeed.portal.PanedPortletController; + import org.apache.jetspeed.services.rundata.JetspeedRunData; /** - * A customized version of the TemplateLink which can handle portlet - * references. - * It is inserted into the template context by the JetspeedVelocityPage. + *

A customized version of the TemplateLink which can handle portlet + * references.

+ * + *

It is inserted into the template context by Turbine, via request tools.

+ * + *

Each portlet must call setPortlet(this) on it before entering the template + * rendering code. This is done currently in VelocityPortlet.

* * @author Rapha�l Luta - * @version $Id: JetspeedTemplateLink.java,v 1.5 2001/07/22 20:31:11 raphael Exp $ + * @author Santiago Gala + * @version $Id: JetspeedTemplateLink.java,v 1.6 2002/03/05 12:26:33 sgala Exp $ */ public class JetspeedTemplateLink extends TemplateLink implements ApplicationTool @@ -82,8 +91,22 @@ public static final String TEMPLATE_KEY = "template"; public static final String PANEL_KEY = "select-panel"; - private String portlet = null; + /** + *

The name of the portlet for which a URL will be generated.

+ */ + private String portletName = null; + + /** + *

Request to which we refer.

+ */ private JetspeedRunData data = null; + + /** + *

The portlet that will be used to build the reference.

+ */ + protected Portlet activePortlet = null; + + /** * Empty constructor.for introspection @@ -95,7 +118,7 @@ /** * Constructor. * - * @param data A Turbine RunData object. + * @param data A Jetspeed RunData object. */ public JetspeedTemplateLink(RunData data) { @@ -129,6 +152,17 @@ } /** + *

Set the portlet giving context to this Link object.

+ * + */ + public void setPortlet(Portlet portlet) + { + this.activePortlet=portlet; + } + + + + /** * Refresh method - does nothing */ public void refresh() @@ -143,25 +177,37 @@ } /** - * Add a portlet reference in the link + * Return a URI that refers to the named portlet. * * @param portlet the name of the portlet to link to - * @return a self reference for easy link construction in template + * @return a DynamicURI referencing the named portlet for easy link construction in template */ - public DynamicURI setPortlet(String portlet) + public DynamicURI forPortlet(String portlet) { - this.portlet=portlet; + this.portletName = portlet; removePathInfo(getPortletKey()); removeQueryData(getPortletKey()); return addPathInfo(getPortletKey(), portlet); } /** + * Add a portlet reference in the link. + * + * @param portlet the name of the portlet to link to + * @deprecated the name is confusing. Use @see(#forPortlet()) instead. + * @return a DynamicURI referencing the named portlet for easy link construction in template + */ + public DynamicURI setPortlet(String portlet) + { + return this.forPortlet( portlet ); + } + + /** * @return the portlet parameter value */ public String getPortlet() { - return this.portlet; + return this.portletName; } /** @@ -204,28 +250,55 @@ */ public DynamicURI setPanel(String panel) { + Log.debug("JetspeedTemplateLink: setPanel(String):" + panel ); removePathInfo(getPanelKey()); removeQueryData(getPanelKey()); return addPathInfo(getPanelKey(), panel); } - /** + /** + *

Use the activePortlet to get the current Panel name (key).

+ * * @return the panel parameter name */ public String getPanelKey() { - return PANEL_KEY; + String panelName = PANEL_KEY; + try + { + PortletController controller = activePortlet.getPortletConfig() + .getPortletSet() + .getController(); + + if (controller instanceof PanedPortletController) + { + panelName=((PanedPortletController)controller).getParameterName(); + } + + } + catch (Exception e) + { + panelName = PANEL_KEY; + } + + return panelName; } - + + /** + * + * + */ public String toString() { - String buf = super.toString(); String tmpl = this.data.getRequestedTemplate(); if (tmpl!=null) { setPage(tmpl); } + String buf = super.toString(); return buf; } + + } 1.2 +3 -1 jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/PortletTemplateLink.java Index: PortletTemplateLink.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/PortletTemplateLink.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PortletTemplateLink.java 27 Aug 2001 15:52:22 -0000 1.1 +++ PortletTemplateLink.java 5 Mar 2002 12:26:33 -0000 1.2 @@ -72,7 +72,9 @@ * if it exists. * * @author Rapha�l Luta - * @version $Id: PortletTemplateLink.java,v 1.1 2001/08/27 15:52:22 raphael Exp $ + * @deprecated Since 2002-03-05. Use JetspeedTemplateLink with the setPortlet(Portlet) method to give + * it the right context. + * @version $Id: PortletTemplateLink.java,v 1.2 2002/03/05 12:26:33 sgala Exp $ */ public class PortletTemplateLink extends JetspeedTemplateLink { -- To unsubscribe, e-mail: For additional commands, e-mail: