KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > util > template > PortletTemplateLink


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 at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * 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 and
14  * limitations under the License.
15  */

16
17 package org.apache.jetspeed.util.template;
18
19 import org.apache.turbine.util.RunData;
20 import org.apache.turbine.util.DynamicURI;
21
22 import org.apache.jetspeed.portal.Portlet;
23 import org.apache.jetspeed.portal.PortletController;
24 import org.apache.jetspeed.portal.PanedPortletController;
25 import org.apache.jetspeed.services.rundata.JetspeedRunData;
26
27
28 /**
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 give
35  * it the right context.
36  * @version $Id: PortletTemplateLink.java,v 1.4 2004/02/23 03:20:45 jford Exp $
37  */

38 public class PortletTemplateLink extends JetspeedTemplateLink
39 {
40         
41     private Portlet portlet = null;
42     private JetspeedRunData data = null;
43     
44     /**
45      * Empty constructor.for introspection
46      */

47     public PortletTemplateLink()
48     {
49     }
50
51     /**
52      * Constructor.
53      *
54      * @param data A Turbine RunData object.
55      */

56     public PortletTemplateLink(RunData data, Portlet portlet)
57     {
58         super(data);
59         this.portlet = portlet;
60     }
61
62     /**
63      * Add a select-panel reference in the link
64      *
65      * @param portlet the name of the portlet to link to
66      * @return a self reference for easy link construction in template
67      */

68     public DynamicURI setPanel(String JavaDoc panel)
69     {
70         removePathInfo(getPanelKey());
71         removeQueryData(getPanelKey());
72         return addPathInfo(getPanelKey(), panel);
73     }
74     
75      /**
76      * @return the panel parameter name
77      */

78     public String JavaDoc getPanelKey()
79     {
80         String JavaDoc panelName = PANEL_KEY;
81         try
82         {
83             PortletController controller = portlet.getPortletConfig()
84                                                   .getPortletSet()
85                                                   .getController();
86
87             if (controller instanceof PanedPortletController)
88             {
89                 panelName=((PanedPortletController)controller).getParameterName();
90             }
91             
92         }
93         catch (Exception JavaDoc e)
94         {
95             panelName = PANEL_KEY;
96         }
97         
98         return panelName;
99     }
100 }
101
Popular Tags