1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.util.template;
1819import org.apache.turbine.util.RunData;
20import org.apache.turbine.util.DynamicURI;
2122import org.apache.jetspeed.portal.Portlet;
23import org.apache.jetspeed.portal.PortletController;
24import org.apache.jetspeed.portal.PanedPortletController;
25import org.apache.jetspeed.services.rundata.JetspeedRunData;
262728/***29 * A customized version of the JetspeedTemplateLink that reacts to the 30 * Portlet context and allows you to manipulate the lowest level pane 31 * if it exists.32 *33 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>34 * @deprecated Since 2002-03-05. Use JetspeedTemplateLink with the setPortlet(Portlet) method to give35 * it the right context.36 * @version $Id: PortletTemplateLink.java,v 1.4 2004/02/23 03:20:45 jford Exp $37 */38publicclassPortletTemplateLinkextendsJetspeedTemplateLink39 {
4041privatePortlet portlet = null;
42privateJetspeedRunData data = null;
4344/***45 * Empty constructor.for introspection46 */47publicPortletTemplateLink()
48 {
49 }
5051/***52 * Constructor.53 *54 * @param data A Turbine RunData object.55 */56publicPortletTemplateLink(RunData data, Portlet portlet)
57 {
58super(data);
59this.portlet = portlet;
60 }
6162/*** 63 * Add a select-panel reference in the link64 *65 * @param portlet the name of the portlet to link to66 * @return a self reference for easy link construction in template67 */68public DynamicURI setPanel(String panel)
69 {
70 removePathInfo(getPanelKey());
71 removeQueryData(getPanelKey());
72return addPathInfo(getPanelKey(), panel);
73 }
7475/*** 76 * @return the panel parameter name77 */78public String getPanelKey()
79 {
80 String panelName = PANEL_KEY;
81try82 {
83PortletController controller = portlet.getPortletConfig()
84 .getPortletSet()
85 .getController();
8687if (controller instanceof PanedPortletController)
88 {
89 panelName=((PanedPortletController)controller).getParameterName();
90 }
9192 }
93catch (Exception e)
94 {
95 panelName = PANEL_KEY;
96 }
9798return panelName;
99 }
100 }