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/DisplayBoxTag.java $
024: //$Author: Dan $
025: //$Revision: 30 $
026: //$Modtime: 7/29/04 11:26a $
027: /////////////////////////
028:
029: import java.io.IOException;
030:
031: import javax.servlet.jsp.JspWriter;
032:
033: import com.salmonllc.html.HtmlComponent;
034: import com.salmonllc.jsp.JspDisplayBox;
035: import com.salmonllc.jsp.TagWriter;
036: import com.salmonllc.util.MessageLog;
037:
038: /**
039: * This is a tag used to create a display box (similar to a window).
040: */
041:
042: public class DisplayBoxTag extends ContainerTag {
043: private String _caption;
044: private String _header;
045: private String _box;
046: private String _backgroundColor;
047: private String _headingBackgroundColor;
048: private String _border;
049: private String _cellPadding;
050: private String _cellSpacing;
051: private String _theme;
052: private String _width;
053: private String _font;
054: private String _dataSource;
055: private String _displayBoxClass;
056:
057: /**
058: * This method creates the JSPDisplayBox used by the tag.
059: */
060:
061: public HtmlComponent createComponent() {
062: JspDisplayBox box = new JspDisplayBox(getName(), getHelper()
063: .getController());
064: if (!BaseTagHelper.isEmpty(_theme))
065: box.setTheme(_theme);
066: if (!BaseTagHelper.isEmpty(_border))
067: box.setBorder(BaseTagHelper.stringToInt(_border));
068: if (!BaseTagHelper.isEmpty(_cellPadding))
069: box.setCellPadding(BaseTagHelper.stringToInt(_cellPadding));
070: if (!BaseTagHelper.isEmpty(_cellSpacing))
071: box.setCellSpacing(BaseTagHelper.stringToInt(_cellSpacing));
072: if (!BaseTagHelper.isEmpty(_width))
073: box.setWidth(_width);
074: if (!BaseTagHelper.isEmpty(_headingBackgroundColor))
075: box.setHeadingBackgroundColor(_headingBackgroundColor);
076: if (!BaseTagHelper.isEmpty(_backgroundColor))
077: box.setBackgroundColor(_backgroundColor);
078: if (!BaseTagHelper.isEmpty(_font))
079: box.setHeaderFont(_font);
080: if (_dataSource != null)
081: box.setDataSource(_dataSource);
082:
083: if (getClassname() != null)
084: box.setClassName(getClassname());
085:
086: box.setHeadingCaption(_caption);
087: return box;
088: }
089:
090: /**
091: * This method generates the html used by the tag.
092: */
093:
094: public void generateComponentHTML(JspWriter p) throws IOException {
095: JspDisplayBox box = (JspDisplayBox) getHelper().getController()
096: .getComponent(getName());
097: if (box == null)
098: return;
099: TagWriter w = getTagWriter();
100: w.setWriter(p);
101: box.generateHTML(w, _header, _box);
102: }
103:
104: /**
105: * Get the tag's background color attribute
106: */
107: public String getBgcolor() {
108: return _backgroundColor;
109: }
110:
111: /**
112: * Get the tag's border attribute
113: */
114: public String getBorder() {
115: return _border;
116: }
117:
118: /**
119: * Get the tag's caption attribute
120: */
121: public String getCaption() {
122: return _caption;
123: }
124:
125: /**
126: * Get the tag's cell padding attribute
127: */
128: public String getCellpadding() {
129: return _cellPadding;
130: }
131:
132: /**
133: * Get the tag's cell spacing attribute
134: */
135: public String getCellspacing() {
136: return _cellSpacing;
137: }
138:
139: /**
140: * Get the Data Source the component should be bound to
141: */
142: public String getDatasource() {
143: return _dataSource;
144: }
145:
146: /**
147: * Get the tag's heading background color attribute.
148: */
149: public String getHeaderbgcolor() {
150: return _headingBackgroundColor;
151: }
152:
153: /**
154: * Get the tag's heading font color attribute.
155: */
156: public String getHeaderfont() {
157: return _font;
158: }
159:
160: /**
161: * Returns the type of DreamWeaver conversion that this tag uses.
162: */
163: public int getTagConvertType() {
164: return CONV_CUSTOM;
165: }
166:
167: /**
168: * Get the tag's theme attribute
169: */
170: public String getTheme() {
171: return _theme;
172: }
173:
174: /**
175: * Get the tag's width attribute
176: */
177: public String getWidth() {
178: return _width;
179: }
180:
181: /**
182: * Override this method for tags that contain NestedTags within to return true
183: */
184: public boolean hasNestedTags() {
185: return true;
186: }
187:
188: /**
189: * For Tags that require multiple passes to render their Html, this method should be implemented. It wll be called for each mode until it returns false. Also, this method is responsible for storing the results of the tags nested within it. Once the method returns false, the generateComponentHtml method will be called and here, the stored data from the nested tags should be sent to the output stream.
190: */
191: public boolean incrementMode() {
192: boolean retVal = false;
193: try {
194: if (getMode() == MODE_HEADER) {
195: _header = getBodyContentData(true);
196: setMode(MODE_BOX);
197: retVal = true;
198: } else {
199: _box = getBodyContentData(true);
200: retVal = false;
201: }
202:
203: return retVal;
204: } catch (Exception e) {
205: MessageLog.writeErrorMessage("incrementMode()", e, this );
206: return false;
207: }
208: }
209:
210: /**
211: * Sets the mode to MODE_HEADER and gets the object ready to render html
212: */
213: public void initMode() {
214: setMode(MODE_HEADER);
215: _header = null;
216: _box = null;
217: }
218:
219: /**
220: * Part of the tag library specification. Clears all resources used by the tag.
221: */
222: public void release() {
223: super .release();
224: _caption = null;
225: _header = null;
226: _box = null;
227: _backgroundColor = null;
228: _headingBackgroundColor = null;
229: _font = null;
230:
231: }
232:
233: /**
234: * Sets the tag's background color attribute
235: */
236: public void setBgcolor(String backgroundColor) {
237: _backgroundColor = backgroundColor;
238: }
239:
240: /**
241: * Sets the tag's border attribute
242: */
243: public void setBorder(String newBorder) {
244: _border = newBorder;
245: }
246:
247: /**
248: * Sets the tag's Caption attribute
249: */
250: public void setCaption(String caption) {
251: _caption = caption;
252: }
253:
254: /**
255: * Sets the tag's cell padding attribute
256: */
257:
258: public void setCellpadding(String newCellPadding) {
259: _cellPadding = newCellPadding;
260: }
261:
262: /**
263: * Sets the tag's cell spacing attribute
264: */
265:
266: public void setCellspacing(String newCellSpacing) {
267: _cellSpacing = newCellSpacing;
268: }
269:
270: /**
271: * Set the Data Source the component should be bound to
272: */
273: public void setDatasource(String val) {
274: _dataSource = val;
275: }
276:
277: /**
278: * Set's the tag's heading background color attribute
279: */
280: public void setHeaderbgcolor(String backgroundColor) {
281: _headingBackgroundColor = backgroundColor;
282: }
283:
284: /**
285: * Set's the tag's heading font attribute
286: */
287: public void setHeaderfont(String font) {
288: _font = font;
289: }
290:
291: /**
292: * Sets the tag's theme attribute
293: */
294:
295: public void setTheme(String newTheme) {
296: _theme = newTheme;
297: }
298:
299: /**
300: * Sets the tag's width attribute
301: */
302:
303: public void setWidth(String newWidth) {
304: _width = newWidth;
305: }
306: }
|