01: //** Copyright Statement ***************************************************
02: //The Salmon Open Framework for Internet Applications (SOFIA)
03: // Copyright (C) 1999 - 2002, Salmon LLC
04: //
05: // This program is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU General Public License version 2
07: // as published by the Free Software Foundation;
08: //
09: // This program is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: // GNU General Public License for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // along with this program; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: //
18: // For more information please visit http://www.salmonllc.com
19: //** End Copyright Statement ***************************************************
20: package com.salmonllc.html;
21:
22: /////////////////////////
23: //$Archive: /JADE/SourceCode/com/salmonllc/html/HtmlScript.java $
24: //$Author: Dan $
25: //$Revision: 10 $
26: //$Modtime: 10/30/02 8:21p $
27: /////////////////////////
28:
29: /**
30: * This type can be used to add javascript to your html page
31: */
32: public class HtmlScript extends HtmlComponent {
33: String _script;
34: String _language;
35:
36: /**
37: * Constructs a new script that can be placed on a page
38: * @param script the script to insert.
39: */
40: public HtmlScript(String script, HtmlPage p) {
41: this (script, null, p);
42: }
43:
44: /**
45: * Constructs a new script that can be placed on a page
46: * @param script java.lang.String
47: * @param language java.lang.String
48: * @param p com.salmonllc.html.HtmlPage
49: */
50: public HtmlScript(String script, String language, HtmlPage p) {
51: super ("", p);
52: _script = script;
53: _language = language;
54: }
55:
56: public void generateHTML(java.io.PrintWriter p, int rowNo) {
57: if (!getVisible())
58: return;
59:
60: if (_script == null)
61: return;
62:
63: p.print("<SCRIPT");
64: if (_language != null && !_language.trim().equals(""))
65: p.print(" LANGUAGE=\"" + _language + "\"");
66: p.println(">");
67: p.println(_script);
68: p.println("</SCRIPT>");
69: }
70:
71: /**
72: * This method returns the script in the component.
73: */
74: public String getScript() {
75: return _script;
76: }
77:
78: /**
79: * This method sets the script that the component will generate.
80: */
81: public void setScript(String script) {
82: _script = script;
83: }
84: }
|