001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.jsp.tags;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/jsp/tags/RawTag.java $
024: //$Author: Dan $
025: //$Revision: 23 $
026: //$Modtime: 7/16/03 8:07p $
027: /////////////////////////
028:
029: import com.salmonllc.html.*;
030: import com.salmonllc.jsp.*;
031:
032: import javax.servlet.jsp.JspWriter;
033: import java.io.IOException;
034: import java.io.PrintWriter;
035:
036: /**
037: * This tag is used to place a piece of Html in a page that can be manipluated by the controller
038: */
039:
040: public class RawTag extends ContainerTag {
041:
042: private String _fileName;
043: /**
044: * srufle 04-09-2002
045: * not being used:
046: * private String _box;
047: */
048: private String _dataSource;
049:
050: public HtmlComponent createComponent() {
051: JspRaw raw = new JspRaw(getName(), null, getHelper()
052: .getController());
053: if (getVisible() != null)
054: raw.setVisible(new Boolean(getVisible()).booleanValue());
055: if (_fileName != null)
056: raw.setFileName(_fileName);
057: if (_dataSource != null)
058: raw.setDataSource(_dataSource);
059:
060: return raw;
061: }
062:
063: /**
064: * This method generates the html used by the tag.
065: */
066:
067: public void generateComponentHTML(JspWriter p) throws IOException {
068: JspRaw raw = (JspRaw) getHelper().getController().getComponent(
069: getName());
070: if (raw == null)
071: return;
072:
073: HtmlComponent comp = getHelper().getComponent();
074: int startRow = -1;
075:
076: DataTableTag dt = getHelper().getDataTableTag();
077: if (dt != null) {
078: startRow = dt.getStartRow();
079: } else {
080: ListTag l = getHelper().getListTag();
081: if (l != null) {
082: startRow = l.getRow();
083: }
084: }
085: if (comp != null) {
086: raw.generateHTML(new PrintWriter(p), startRow);
087: }
088:
089: }
090:
091: /**
092: * Get the Data Source the component should be bound to
093: */
094: public String getDatasource() {
095: return _dataSource;
096: }
097:
098: /**
099: * Returns the file name used attribute
100: */
101: public String getFilename() {
102: return _fileName;
103: }
104:
105: /**
106: * Returns the type of DreamWeaver conversion that this tag uses.
107: */
108: public int getTagConvertType() {
109: return CONV_INVISIBLE;
110: }
111:
112: public boolean incrementMode() {
113: clearBodyContent();
114: return false;
115:
116: }
117:
118: /**
119: * For tags requiring more than one pass to complete, this method should be implemented. It should initialize the mode to whatever is the starting mode for the component and perform any other initializetion tasks.
120: */
121: public void initMode() {
122: //commented this out because it was causing a problem with tag pooling in Tomcat 4.1
123: // clearBodyContent();
124: }
125:
126: public void release() {
127: super .release();
128:
129: }
130:
131: /**
132: * Set the Data Source the component should be bound to
133: */
134:
135: public void setDatasource(String val) {
136: _dataSource = val;
137: }
138:
139: /**
140: * Sets the file name attribute
141: */
142:
143: public void setFilename(String val) {
144: _fileName = val;
145: }
146:
147: /**
148: * This method can be used by components that need to change a component after all the sub tags have been initialized.
149: */
150: public void afterInit(HtmlComponent comp) {
151: super .afterInit(comp);
152: String html = getBodyContentData(true);
153: ((JspRaw) comp).setHtml(html);
154: }
155:
156: /**
157: * @return true so the body content always gets written
158: */
159: public boolean alwaysWriteContent() {
160: return true;
161: }
162:
163: }
|