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/ATag.java $
024: //$Author: Len $
025: //$Revision: 21 $
026: //$Modtime: 11/10/04 10:41a $
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.JspWriter;
035: import java.io.IOException;
036:
037: /**
038: * This is a tag used to create a HtmlLink box (similar to a window).
039: */
040:
041: public class ATag extends ContainerTag {
042: private String _box;
043: private String _href;
044: // private String _class;
045: private String _target;
046: private String _onClick;
047: private String _onMouseOver;
048: private String _onMouseOut;
049: private String _dataSource;
050: private String _bracket;
051: private String _bracketFont;
052: //Added 18-Jul-2003 AT
053: private String _title;
054:
055: /**
056: * This method creates the JSPLink used by the tag.
057: */
058:
059: public HtmlComponent createComponent() {
060: JspLink link = new JspLink(getName(), _href, getHelper()
061: .getController());
062: if (_target != null)
063: link.setTarget(_target);
064: if (_onClick != null)
065: link.setOnClick(_onClick);
066: if (_onMouseOver != null)
067: link.setOnMouseOver(_onMouseOver);
068: if (_onMouseOut != null)
069: link.setOnMouseOut(_onMouseOut);
070: if (getClassname() != null)
071: link.setStyle(getClassname());
072: if (_dataSource != null)
073: link.setDataSource(_dataSource);
074: if (_bracket != null) {
075: link.setBracket(BaseTagHelper.stringToBoolean(getBracket(),
076: false));
077: if (_bracketFont != null)
078: link.setBracketFont(_bracketFont);
079: }
080: return link;
081: }
082:
083: /**
084: * This method generates the html used by the tag.
085: */
086:
087: public void generateComponentHTML(JspWriter p) throws IOException {
088: JspLink link = (JspLink) getHelper().getController()
089: .getComponent(getName());
090: if (link == null)
091: return;
092: HtmlComponent comp = getHelper().getComponent();
093: int startRow = -1;
094: if (_title != null)
095: link.setTitle(_title);
096: DataTableTag dt = getHelper().getDataTableTag();
097: ListTag l = getHelper().getListTag();
098: if (l != null
099: && dt != null
100: && (DataTableTag) findAncestorWithClass(l,
101: DataTableTag.class) == dt) {
102: dt = null;
103: }
104: if (dt != null) {
105: startRow = dt.getStartRow();
106: } else {
107: if (l != null) {
108: startRow = l.getRow();
109: }
110: }
111: if (comp != null) {
112: TagWriter w = getTagWriter();
113: w.setWriter(p);
114: link.generateHTML(w, _box, startRow);
115: }
116: }
117:
118: /**
119: * Get the tag's bracket attribute
120: */
121: public String getBracket() {
122: return _bracket;
123: }
124:
125: /**
126: * Get the Data Source the component should be bound to
127: */
128: public String getDatasource() {
129: return _dataSource;
130: }
131:
132: /**
133: * Get the tag's Href attribute
134: */
135: public String getHref() {
136: return _href;
137: }
138:
139: /**
140: * Get the tag's onClick attribute
141: */
142: public String getOnclick() {
143: return _onClick;
144: }
145:
146: /**
147: * Get the tag's on mouse out attribute
148: */
149: public String getOnmouseout() {
150: return _onMouseOut;
151: }
152:
153: /**
154: * Get the tag's on mouse over attribute
155: */
156: public String getOnmouseover() {
157: return _onMouseOver;
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 target attribute
169: */
170: public String getTarget() {
171: return _target;
172: }
173:
174: /**
175: * 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.
176: */
177: public boolean incrementMode() {
178: try {
179: _box = getBodyContentData(true);
180: return false;
181: }
182:
183: catch (Exception e) {
184: MessageLog.writeErrorMessage("incrementMode()", e, this );
185: return false;
186: }
187: }
188:
189: /**
190: * 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.
191: */
192: public void initMode() {
193: _box = null;
194: }
195:
196: /**
197: * Part of the tag library specification. Clears all resources used by the tag.
198: */
199: public void release() {
200: super .release();
201: _href = null;
202: _box = null;
203: _bracket = null;
204: _bracketFont = null;
205:
206: }
207:
208: /**
209: * Set the Brackets if the component should be have brackets around it.
210: */
211: public void setBracket(String val) {
212: _bracket = val;
213: }
214:
215: /**
216: * Set the Brackets Font of the component when brackets are around it.
217: */
218: public void setBracketfont(String val) {
219: _bracketFont = val;
220: }
221:
222: /**
223: * Set the Data Source the component should be bound to
224: */
225: public void setDatasource(String val) {
226: _dataSource = val;
227: }
228:
229: /**
230: * Sets the tag's href color attribute
231: */
232: public void setHref(String href) {
233: _href = href;
234: }
235:
236: /**
237: * Sets the tag's onclick attribute
238: */
239: public void setOnclick(String val) {
240: _onClick = val;
241: }
242:
243: /**
244: * Sets the tag's On Mouse Out attribute
245: */
246: public void setOnmouseout(String val) {
247: _onMouseOut = val;
248: }
249:
250: /**
251: * Sets the tag's On mouse over attribute
252: */
253: public void setOnmouseover(String val) {
254: _onMouseOver = val;
255: }
256:
257: /**
258: * Sets the tag's target attribute
259: */
260: public void setTarget(String val) {
261: _target = val;
262: }
263:
264: /**
265: * @return
266: */
267: public String getTitle() {
268: return _title;
269: }
270:
271: /**
272: * @param string
273: */
274: public void setTitle(String string) {
275: _title = string;
276: }
277:
278: }
|