1 package org.apache.turbine.modules.screens;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 264148 2005-08-29 14:21:04Z henning $
36 */
37 public class BaseJspScreen
38 extends TemplateScreen
39 {
40 /*** The prefix for lookup up screen pages */
41 private String 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
52 {
53 String screenTemplate = data.getTemplateInfo().getScreenTemplate();
54
55 String templateName
56 = TurbineTemplate.getScreenTemplateName(screenTemplate);
57
58
59 if (StringUtils.isEmpty(templateName))
60 {
61 log.error("Screen " + screenTemplate + " not found!");
62 throw new Exception("Could not find screen for " + screenTemplate);
63 }
64
65
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
80 {
81 }
82 }