01: package org.apache.turbine.modules.screens;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.commons.lang.StringUtils;
23:
24: import org.apache.ecs.ConcreteElement;
25:
26: import org.apache.turbine.TurbineConstants;
27: import org.apache.turbine.services.jsp.TurbineJsp;
28: import org.apache.turbine.services.template.TurbineTemplate;
29: import org.apache.turbine.util.RunData;
30:
31: /**
32: * Base JSP Screen that should be subclassed by screens that want to
33: * use JSP. Subclasses should override the doBuildTemplate() method.
34: *
35: * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
36: * @author Frank Y. Kim
37: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
38: * @version $Id: BaseJspScreen.java 534527 2007-05-02 16:10:59Z tv $
39: */
40: public class BaseJspScreen extends TemplateScreen {
41: /** The prefix for lookup up screen pages */
42: private String prefix = TurbineConstants.SCREEN_PREFIX + "/";
43:
44: /**
45: * Method that sets up beans and forward the request to the JSP.
46: *
47: * @param data Turbine information.
48: * @return null - the JSP sends the information.
49: * @exception Exception, a generic exception.
50: */
51: public ConcreteElement buildTemplate(RunData data) throws Exception {
52: String screenTemplate = data.getTemplateInfo()
53: .getScreenTemplate();
54: // get the name of the JSP we want to use
55: String templateName = TurbineTemplate
56: .getScreenTemplateName(screenTemplate);
57:
58: // The Template Service could not find the Screen
59: if (StringUtils.isEmpty(templateName)) {
60: log.error("Screen " + screenTemplate + " not found!");
61: throw new Exception("Could not find screen for "
62: + 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) throws Exception {
79: }
80: }
|