1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.modules.actions.portlets;
18
19
20 import java.lang.reflect.Method;
21
22 import org.apache.jetspeed.portal.Portlet;
23 import org.apache.jetspeed.portal.portlets.VelocityPortlet;
24
25
26
27 import org.apache.turbine.util.RunData;
28
29
30
31 import org.apache.velocity.context.Context;
32
33
34 /***
35 * An abstract action class to build VelocityPortlet actions.
36 *
37 * <p>Don't call it from the URL, the Portlet and the Action are automatically
38 * associated through the registry PortletName
39 * <p>
40 * <strong>NOTE:</strong>This supports the pre-MVC style of template based
41 * portlet development and is supplied for backward compatibility. It is
42 * suggested you use a combination of
43 * @see org.apache.jetspeed.portal.portlets.GenericMVCPortlet along with
44 * subclassing @see org.apache.jetspeed.portal.portlets.GenericMVCAction
45 * for future portlet development.
46 * </p>
47 *
48 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>
49 * @author <a href="mailto:re_carrasco@bco011.sonda.cl">Roberto Carrasco</a>
50 *
51 * @version $Id: VelocityPortletAction.java,v 1.14 2004/02/23 02:56:58 jford Exp $
52 */
53 public abstract class VelocityPortletAction extends GenericMVCAction
54 {
55
56
57
58 /***
59 * Subclasses must override this method to provide default behavior
60 * for the portlet action
61 */
62 protected abstract void buildNormalContext(VelocityPortlet portlet,
63 Context context,
64 RunData rundata)
65 throws Exception;
66
67 /***
68 * STW: Backwards compatibility so the overriden method is called specifically using a cast to VelocityPortlet
69 * @see org.apache.jetspeed.portal.portlets.mvc.PortletAction#buildNormalContext(Portlet, Context, RunData)
70 */
71 protected void buildNormalContext(Portlet portlet, Context context, RunData data)
72 throws Exception
73 {
74 buildNormalContext((VelocityPortlet) portlet, context, data);
75 }
76
77 /***
78 * @see org.apache.jetspeed.portal.portlets.mvc.PortletAction#buildConfigureContext(Portlet, Context, RunData)
79 */
80 protected void buildConfigureContext(Portlet portlet, Context context, RunData data)
81 throws Exception
82 {
83
84
85
86
87
88
89
90
91
92
93
94 try
95 {
96 Method method =
97 this.getClass().getDeclaredMethod(
98 "buildConfigureContext",
99 new Class[] { VelocityPortlet.class, Context.class, RunData.class });
100 method.setAccessible(true);
101 method.invoke(this, new Object[] { portlet, context, data });
102 method.setAccessible(false);
103
104 }
105 catch (NoSuchMethodException e)
106 {
107
108 super.buildConfigureContext(portlet, context, data);
109 }
110
111 }
112
113 /***
114 * prevents possible self-referencing loop when sub-classes invoke super.buildConfigureContext().
115 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
116 */
117 protected void buildConfigureContext(VelocityPortlet portlet, Context context, RunData data)
118 throws Exception
119 {
120 }
121
122
123 protected void buildMaximizedContext(Portlet portlet, Context context, RunData data)
124 throws Exception
125 {
126
127
128
129
130
131
132
133
134
135
136
137 try
138 {
139 Method method =
140 this.getClass().getDeclaredMethod(
141 "buildMaximizedContext",
142 new Class[] { VelocityPortlet.class, Context.class, RunData.class });
143 method.setAccessible(true);
144 method.invoke(this, new Object[] { portlet, context, data });
145 method.setAccessible(false);
146 }
147 catch (NoSuchMethodException e)
148 {
149
150 super.buildMaximizedContext(portlet, context, data);
151 }
152 }
153
154 /***
155 * prevents possible self-referencing loop when sub-classes invoke super.buildMaximizedContext().
156 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
157 */
158 protected void buildMaximizedContext(VelocityPortlet portlet, Context context, RunData data)
159 throws Exception
160 {
161 }
162
163
164
165
166 }