1 package org.apache.turbine.modules;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.ecs.ConcreteElement;
20
21 import org.apache.turbine.util.InputFilterUtils;
22 import org.apache.turbine.util.RunData;
23
24 /***
25 * This is the base class which defines the Screen modules.
26 *
27 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
28 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
29 * @version $Id: Screen.java 264148 2005-08-29 14:21:04Z henning $
30 */
31 public abstract class Screen
32 extends Assembler
33 {
34 /***
35 * A subclass must override this method to build itself.
36 * Subclasses override this method to store the screen in RunData
37 * or to write the screen to the output stream referenced in
38 * RunData.
39 *
40 * @param data Turbine information.
41 * @exception Exception a generic exception.
42 */
43 protected abstract ConcreteElement doBuild(RunData data)
44 throws Exception;
45
46 /***
47 * Subclasses can override this method to add additional
48 * functionality. This method is protected to force clients to
49 * use ScreenLoader to build a Screen.
50 *
51 * @param data Turbine information.
52 * @exception Exception a generic exception.
53 */
54 protected ConcreteElement build(RunData data)
55 throws Exception
56 {
57 return doBuild(data);
58 }
59
60 /***
61 * If the Layout has not been defined by the Screen then set the
62 * layout to be "DefaultLayout". The Screen object can also
63 * override this method to provide intelligent determination of
64 * the Layout to execute. You can also define that logic here as
65 * well if you want it to apply on a global scale. For example,
66 * if you wanted to allow someone to define Layout "preferences"
67 * where they could dynamically change the Layout for the entire
68 * site. The information for the request is passed in with the
69 * RunData object.
70 *
71 * @param data Turbine information.
72 * @return A String with the Layout.
73 */
74 public String getLayout(RunData data)
75 {
76 return data.getLayout();
77 }
78
79 /***
80 * Set the layout for a Screen.
81 *
82 * @param data Turbine information.
83 * @param layout The layout name.
84 */
85 public void setLayout(RunData data, String layout)
86 {
87 data.setLayout(layout);
88 }
89
90 /***
91 * This function can/should be used in any screen that will output
92 * User entered text. This will help prevent users from entering
93 * html (<SCRIPT>) tags that will get executed by the browser.
94 *
95 * @param s The string to prepare.
96 * @return A string with the input already prepared.
97 * @deprecated Use InputFilterUtils.prepareText(String s)
98 */
99 public static String prepareText(String s)
100 {
101 return InputFilterUtils.prepareText(s);
102 }
103
104 /***
105 * This function can/should be used in any screen that will output
106 * User entered text. This will help prevent users from entering
107 * html (<SCRIPT>) tags that will get executed by the browser.
108 *
109 * @param s The string to prepare.
110 * @return A string with the input already prepared.
111 * @deprecated Use InputFilterUtils.prepareTextMinimum(String s)
112 */
113 public static String prepareTextMinimum(String s)
114 {
115 return InputFilterUtils.prepareTextMinimum(s);
116 }
117 }