KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > modules > actions > JspAction


1 package org.apache.turbine.modules.actions;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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,v 1.1.2.2 2004/05/20 03:03:07 seade Exp $
34  */

35 public abstract class JspAction extends JspActionEvent
36 {
37     /**
38      * You SHOULD NOT override this method and implement it in your
39      * action.
40      *
41      * @param data Turbine information.
42      * @exception Exception, a generic exception.
43      */

44     public void doPerform(RunData data)
45         throws Exception JavaDoc
46     {
47         doPerform(data, getContext(data));
48     }
49
50     /**
51      * You SHOULD override this method and implement it in your
52      * action.
53      *
54      * @param data Turbine information.
55      * @param context Context for web pages.
56      * @exception Exception, a generic exception.
57      */

58     public abstract void doPerform(RunData data,
59                                    Context context)
60         throws Exception JavaDoc;
61
62     /**
63      * Sets up the context and then calls super.perform(); thus,
64      * subclasses don't have to worry about getting a context
65      * themselves!
66      *
67      * @param data Turbine information.
68      * @exception Exception, a generic exception.
69      */

70     protected void perform(RunData data)
71         throws Exception JavaDoc
72     {
73         super.perform(data);
74     }
75
76     /**
77      * This method is used when you want to short circuit an Action
78      * and change the template that will be executed next.
79      *
80      * @param data Turbine information.
81      * @param template The template that will be executed next.
82      */

83     public void setTemplate(RunData data,
84                             String JavaDoc template)
85     {
86         TemplateScreen.setTemplate(data, template);
87     }
88
89     /**
90      * Return the Context needed by Jsp.
91      *
92      * @param RunData data
93      * @return Context, a context for web pages.
94      */

95     protected Context getContext(RunData data)
96     {
97         return TurbineJsp.getContext(data);
98     }
99 }
100
101
Popular Tags