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/TrTag.java $
024: //$Author: Dan $
025: //$Revision: 25 $
026: //$Modtime: 10/21/04 1:29p $
027: /////////////////////////
028:
029: import com.salmonllc.util.MessageLog;
030:
031: import com.salmonllc.html.*;
032: import com.salmonllc.jsp.*;
033:
034: import javax.servlet.jsp.JspException;
035: import javax.servlet.jsp.JspWriter;
036: import java.io.IOException;
037:
038: /**
039: * This handler implements the table definition (TD) tag
040: */
041: public class TrTag extends ContainerTag {
042: private String _align;
043: private String _valign;
044: private String _bgcolor;
045: private String _content;
046: private String _generatedName = null;
047:
048: // private String _class = null;
049:
050: /**
051: * This method creates the JSPTableRow used by the tag.
052: */
053:
054: public HtmlComponent createComponent() {
055: JspTableRow row = new JspTableRow(getName(), getHelper()
056: .getController());
057:
058: row.setAlign(_align);
059: row.setBackgroundColor(_bgcolor);
060: row.setVertAlign(_valign);
061: row.setStyle(getClassname());
062:
063: return row;
064: }
065:
066: /**
067: * This method generates the html used by the tag.
068: */
069:
070: public void generateComponentHTML(JspWriter p) throws IOException {
071: String backgroundColor = null;
072: String styleClass = null;
073: int rowNo = -1;
074:
075: DataTableTag dtt = getHelper().getDataTableTag(true);
076:
077: if (dtt != null) {
078: JspDataTable dt = (JspDataTable) dtt.getHelper()
079: .getComponent();
080: backgroundColor = dtt.getCurrentBackgroundColor();
081: styleClass = dtt.getCurrentStyle();
082: rowNo = dtt.getStartRow();
083: }
084: TableTag tt = getHelper().getTableTag(true);
085: if (tt != null) {
086: JspTable t = (JspTable) tt.getHelper().getComponent();
087: backgroundColor = tt.getCurrentBackgroundColor();
088: styleClass = tt.getCurrentRowStyle();
089: }
090:
091: JspTableRow row = (JspTableRow) getHelper().getController()
092: .getComponent(getName());
093: if (row == null)
094: return;
095:
096: TagWriter w = getTagWriter();
097: w.setWriter(p);
098: row.generateHTML(w, _content, backgroundColor, styleClass,
099: rowNo);
100: }
101:
102: /**
103: * Gets the align property for the tag
104: */
105:
106: public String getAlign() {
107: return _align;
108: }
109:
110: /**
111: * Gets the background color property for the tag
112: */
113: public String getBgcolor() {
114: return _bgcolor;
115: }
116:
117: /**
118: * Gets the generated name property for the tag
119: */
120:
121: public String getGeneratedName() {
122: return _generatedName;
123: }
124:
125: /**
126: * Gets the name for the tag
127: */
128:
129: public String getName() {
130: String name = super .getName();
131: if (name == null)
132: return _generatedName;
133: else
134: return name;
135: }
136:
137: /**
138: * Gets the vertical align property for the tag
139: */
140:
141: public String getValign() {
142: return _valign;
143: }
144:
145: public boolean incrementMode() {
146: try {
147: _content = getBodyContentData(true);
148: return false;
149: } catch (Exception e) {
150: MessageLog.writeErrorMessage("incrementMode()", e, this );
151: return false;
152: }
153: }
154:
155: /**
156: * Gets the object ready to render html
157: */
158: public void initMode() {
159: _content = null;
160: }
161:
162: public void generateName() {
163: if (super .getName() != null)
164: return;
165: DataTableTag dtt = getHelper().getDataTableTag(true);
166: if (dtt != null) {
167: JspDataTable dt = (JspDataTable) dtt.getHelper()
168: .getComponent();
169: _generatedName = dt.generateNextTRName(getHelper()
170: .getComponentType());
171: dtt.resetColCounter();
172: }
173: TableTag tt = getHelper().getTableTag(true);
174: if (tt != null) {
175: JspTable t = (JspTable) tt.getHelper().getComponent();
176: _generatedName = t.generateNextTRName();
177: }
178: }
179:
180: /**
181: * Releases any resources used by the tag.
182: */
183:
184: public void release() {
185: super .release();
186: _align = null;
187: _valign = null;
188: _bgcolor = null;
189: _generatedName = null;
190:
191: }
192:
193: /**
194: * Sets the align property for the tag
195: */
196:
197: public void setAlign(String value) {
198: _align = value;
199: }
200:
201: /**
202: * Sets the background color property for the tag
203: */
204:
205: public void setBgcolor(String color) {
206: _bgcolor = color;
207: }
208:
209: /**
210: * Sets the vertical align property for the tag
211: */
212:
213: public void setValign(String value) {
214: _valign = value;
215: }
216:
217: /**
218: * Returns the type of DreamWeaver conversion that this tag uses.
219: */
220: public int getTagConvertType() {
221: return CONV_CUSTOM;
222: }
223:
224: public int doStartTag() throws JspException {
225: generateName();
226: return super.doStartTag();
227: }
228:
229: }
|