KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > modules > screens > BaseJspScreen


1 package org.apache.turbine.modules.screens;
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.commons.lang.StringUtils;
20
21 import org.apache.ecs.ConcreteElement;
22
23 import org.apache.turbine.TurbineConstants;
24 import org.apache.turbine.services.jsp.TurbineJsp;
25 import org.apache.turbine.services.template.TurbineTemplate;
26 import org.apache.turbine.util.RunData;
27
28 /**
29  * Base JSP Screen that should be subclassed by screens that want to
30  * use JSP. Subclasses should override the doBuildTemplate() method.
31  *
32  * @author <a HREF="mailto:john.mcnally@clearink.com">John D. McNally</a>
33  * @author Frank Y. Kim
34  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
35  * @version $Id: BaseJspScreen.java,v 1.6.2.3 2004/08/14 20:11:41 henning Exp $
36  */

37 public class BaseJspScreen
38         extends TemplateScreen
39 {
40     /** The prefix for lookup up screen pages */
41     private String JavaDoc prefix = TurbineConstants.SCREEN_PREFIX + "/";
42
43     /**
44      * Method that sets up beans and forward the request to the JSP.
45      *
46      * @param data Turbine information.
47      * @return null - the JSP sends the information.
48      * @exception Exception, a generic exception.
49      */

50     public ConcreteElement buildTemplate(RunData data)
51             throws Exception JavaDoc
52     {
53         String JavaDoc screenTemplate = data.getTemplateInfo().getScreenTemplate();
54         // get the name of the JSP we want to use
55
String JavaDoc templateName
56             = TurbineTemplate.getScreenTemplateName(screenTemplate);
57
58         // The Template Service could not find the Screen
59
if (StringUtils.isEmpty(templateName))
60         {
61             log.error("Screen " + screenTemplate + " not found!");
62             throw new Exception JavaDoc("Could not find screen for " + screenTemplate);
63         }
64
65         // let service know whether we are using a layout
66
TurbineJsp.handleRequest(data, prefix + templateName,
67                                  getLayout(data) == null);
68
69         return null;
70     }
71
72     /**
73      * Method to be overidden by subclasses to include data in beans, etc.
74      *
75      * @param data, the Rundata object
76      * @exception Exception, a generic exception.
77      */

78     protected void doBuildTemplate(RunData data)
79         throws Exception JavaDoc
80     {
81     }
82 }
83
Popular Tags