01: package org.apache.turbine.modules.actions;
02:
03: /*
04: * Copyright 2001-2004 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License")
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.apache.turbine.modules.screens.TemplateScreen;
20: import org.apache.turbine.services.jsp.TurbineJsp;
21: import org.apache.turbine.util.RunData;
22: import org.apache.turbine.util.jsp.JspActionEvent;
23: import org.apache.velocity.context.Context;
24:
25: /**
26: * This class provides a convenience methods for Jsp Actions
27: * to use. Since this class is abstract, it should only be extended
28: * and not used directly.
29: *
30: * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
31: * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
32: * @author <a href="mailto:gabrielm@itcsoluciones.com">Gabriel A. Moreno</a>
33: * @version $Id: JspAction.java 221882 2004-05-20 03:06:52Z seade $
34: */
35: public abstract class JspAction extends JspActionEvent {
36: /**
37: * You SHOULD NOT override this method and implement it in your
38: * action.
39: *
40: * @param data Turbine information.
41: * @exception Exception, a generic exception.
42: */
43: public void doPerform(RunData data) throws Exception {
44: doPerform(data, getContext(data));
45: }
46:
47: /**
48: * You SHOULD override this method and implement it in your
49: * action.
50: *
51: * @param data Turbine information.
52: * @param context Context for web pages.
53: * @exception Exception, a generic exception.
54: */
55: public abstract void doPerform(RunData data, Context context)
56: throws Exception;
57:
58: /**
59: * Sets up the context and then calls super.perform(); thus,
60: * subclasses don't have to worry about getting a context
61: * themselves!
62: *
63: * @param data Turbine information.
64: * @exception Exception, a generic exception.
65: */
66: protected void perform(RunData data) throws Exception {
67: super .perform(data);
68: }
69:
70: /**
71: * This method is used when you want to short circuit an Action
72: * and change the template that will be executed next.
73: *
74: * @param data Turbine information.
75: * @param template The template that will be executed next.
76: */
77: public void setTemplate(RunData data, String template) {
78: TemplateScreen.setTemplate(data, template);
79: }
80:
81: /**
82: * Return the Context needed by Jsp.
83: *
84: * @param RunData data
85: * @return Context, a context for web pages.
86: */
87: protected Context getContext(RunData data) {
88: return TurbineJsp.getContext(data);
89: }
90: }
|