001: package org.apache.turbine.modules;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.ecs.ConcreteElement;
023:
024: import org.apache.turbine.util.InputFilterUtils;
025: import org.apache.turbine.util.RunData;
026:
027: /**
028: * This is the base class which defines the Screen modules.
029: *
030: * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
031: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
032: * @version $Id: Screen.java 534527 2007-05-02 16:10:59Z tv $
033: */
034: public abstract class Screen extends Assembler {
035: /**
036: * A subclass must override this method to build itself.
037: * Subclasses override this method to store the screen in RunData
038: * or to write the screen to the output stream referenced in
039: * RunData.
040: *
041: * @param data Turbine information.
042: * @exception Exception a generic exception.
043: */
044: protected abstract ConcreteElement doBuild(RunData data)
045: throws Exception;
046:
047: /**
048: * Subclasses can override this method to add additional
049: * functionality. This method is protected to force clients to
050: * use ScreenLoader to build a Screen.
051: *
052: * @param data Turbine information.
053: * @exception Exception a generic exception.
054: */
055: protected ConcreteElement build(RunData data) throws Exception {
056: return doBuild(data);
057: }
058:
059: /**
060: * If the Layout has not been defined by the Screen then set the
061: * layout to be "DefaultLayout". The Screen object can also
062: * override this method to provide intelligent determination of
063: * the Layout to execute. You can also define that logic here as
064: * well if you want it to apply on a global scale. For example,
065: * if you wanted to allow someone to define Layout "preferences"
066: * where they could dynamically change the Layout for the entire
067: * site. The information for the request is passed in with the
068: * RunData object.
069: *
070: * @param data Turbine information.
071: * @return A String with the Layout.
072: */
073: public String getLayout(RunData data) {
074: return data.getLayout();
075: }
076:
077: /**
078: * Set the layout for a Screen.
079: *
080: * @param data Turbine information.
081: * @param layout The layout name.
082: */
083: public void setLayout(RunData data, String layout) {
084: data.setLayout(layout);
085: }
086:
087: /**
088: * This function can/should be used in any screen that will output
089: * User entered text. This will help prevent users from entering
090: * html (<SCRIPT>) tags that will get executed by the browser.
091: *
092: * @param s The string to prepare.
093: * @return A string with the input already prepared.
094: * @deprecated Use InputFilterUtils.prepareText(String s)
095: */
096: public static String prepareText(String s) {
097: return InputFilterUtils.prepareText(s);
098: }
099:
100: /**
101: * This function can/should be used in any screen that will output
102: * User entered text. This will help prevent users from entering
103: * html (<SCRIPT>) tags that will get executed by the browser.
104: *
105: * @param s The string to prepare.
106: * @return A string with the input already prepared.
107: * @deprecated Use InputFilterUtils.prepareTextMinimum(String s)
108: */
109: public static String prepareTextMinimum(String s) {
110: return InputFilterUtils.prepareTextMinimum(s);
111: }
112: }
|