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
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
41 extends TemplateScreen
42 {
43 /*** The prefix for lookup up screen pages */
44 private String prefix = TurbineConstants.SCREEN_PREFIX + "/";
45
46 /***
47 * Method that sets up beans and forward the request to the JSP.
48 *
49 * @param data Turbine information.
50 * @return null - the JSP sends the information.
51 * @exception Exception, a generic exception.
52 */
53 public ConcreteElement buildTemplate(RunData data)
54 throws Exception
55 {
56 String screenTemplate = data.getTemplateInfo().getScreenTemplate();
57
58 String templateName
59 = TurbineTemplate.getScreenTemplateName(screenTemplate);
60
61
62 if (StringUtils.isEmpty(templateName))
63 {
64 log.error("Screen " + screenTemplate + " not found!");
65 throw new Exception("Could not find screen for " + screenTemplate);
66 }
67
68
69 TurbineJsp.handleRequest(data, prefix + templateName,
70 getLayout(data) == null);
71
72 return null;
73 }
74
75 /***
76 * Method to be overidden by subclasses to include data in beans, etc.
77 *
78 * @param data, the Rundata object
79 * @exception Exception, a generic exception.
80 */
81 protected void doBuildTemplate(RunData data)
82 throws Exception
83 {
84 }
85 }