01: package org.apache.turbine.modules.screens;
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.ecs.ConcreteElement;
20: import org.apache.turbine.services.jsp.JspService;
21: import org.apache.turbine.services.TurbineServices;
22: import org.apache.turbine.services.template.TurbineTemplate;
23: import org.apache.turbine.util.RunData;
24: import org.apache.velocity.context.Context;
25: import org.apache.turbine.services.jsp.TurbineJsp;
26:
27: /**
28: * Jsp Screen with support for conext. The buildTemplate() assumes the
29: * template parameter has been set in the RunData object. This provides
30: * the ability to execute several templates from one Screen.
31: *
32: * <p>
33: *
34: * If you need more specific behavior in your application, extend this
35: * class and override the doBuildTemplate() method.
36: *
37: * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
38: * @author <a href="mailto:gabrielm@itcsoluciones.com">Gabriel A. Moreno</a>
39: * @version $Id: JspScreen.java 221882 2004-05-20 03:06:52Z seade $
40: */
41: public class JspScreen extends BaseJspScreen {
42:
43: /**
44: * Jsp Screens extending this class should overide this
45: * method to perform any particular business logic and add
46: * information to the context.
47: *
48: * @param data Turbine information.
49: * @param context Context for web pages.
50: * @exception Exception, a generic exception.
51: */
52: protected void doBuildTemplate(RunData data, Context context)
53: throws Exception {
54: }
55:
56: /**
57: * Needs to be implemented to make TemplateScreen like us. The
58: * actual method that you should override is the one with the
59: * context in the parameter list.
60: *
61: * @param data Turbine information.
62: * @exception Exception, a generic exception.
63: */
64: protected void doBuildTemplate(RunData data) throws Exception {
65: doBuildTemplate(data, TurbineJsp.getContext(data));
66: }
67:
68: /**
69: * Return the Context needed which can then be used in the Jsp template
70: *
71: * @param data Turbine information.
72: * @return A Context.
73: */
74: public static Context getContext(RunData data) {
75: return TurbineJsp.getContext(data);
76: }
77:
78: }
|