001: package com.salmonllc.jsp.tags;
002:
003: ////////////////////////////////////////////////////////////
004: //$Archive: /SOFIA/SourceCode/com/salmonllc/jsp/tags/AppletTag.java $
005: //$Author: Dan $
006: //$Revision: 6 $
007: //$Modtime: 6/16/03 5:31p $
008: ////////////////////////////////////////////////////////////
009:
010: import com.salmonllc.html.*;
011: import com.salmonllc.jsp.Constants;
012:
013: import javax.servlet.jsp.JspWriter;
014:
015: /**
016: * This tag approximately corresponds to the HTML tag "INPUT"
017: */
018:
019: public class AppletTag extends BaseBodyTag {
020: private String _code, _codeBase, _archive, _alt, _align, _object,
021: _title;
022: private String _mayScript;
023: private String _value, _state;
024: private String _interactWithForm;
025: private String _usePlugin;
026: private String _pluginClassId, _pluginCodeBase;
027: private String _type;
028: private String _pluginsPage;
029: private String _height;
030: private String _width;
031: private String _hspace;
032: private String _vspace;
033: private String _nojavasupport;
034: private String _appletdatasource;
035:
036: /**
037: * Creates the component to be used by the tag.
038: */
039: public HtmlComponent createComponent() {
040: HtmlApplet applet = new HtmlApplet(getName(), _value,
041: getHelper().getController());
042: if (getVisible() != null
043: && getVisible().startsWith(_appletdatasource + ":"))
044: applet.setVisible(getVisible());
045: else
046: applet.setVisible(BaseTagHelper.stringToBoolean(
047: getVisible(), true));
048: applet.setValue(_value);
049: applet.setAlign(_align);
050: applet.setAltText(_alt);
051: if (_height != null) {
052: if (_height.endsWith("%")
053: || _height.startsWith(_appletdatasource + ":"))
054: applet.setHeight(_height);
055: else
056: applet
057: .setHeight(BaseTagHelper.stringToInt(_height,
058: -1));
059: }
060: if (_width != null) {
061: if (_width.endsWith("%")
062: || _width.startsWith(_appletdatasource + ":"))
063: applet.setWidth(_width);
064: else
065: applet.setWidth(BaseTagHelper.stringToInt(_width, -1));
066: }
067: if (_hspace != null) {
068: if (_hspace.startsWith(_appletdatasource + ":"))
069: applet.setHSpace(_hspace);
070: else
071: applet
072: .setHSpace(BaseTagHelper.stringToInt(_hspace,
073: -1));
074: }
075: if (_vspace != null) {
076: if (_vspace.startsWith(_appletdatasource + ":"))
077: applet.setVSpace(_vspace);
078: else
079: applet
080: .setVSpace(BaseTagHelper.stringToInt(_vspace,
081: -1));
082: }
083: applet.setAppletAttributesDatasource(_appletdatasource);
084: applet.setArchive(_archive);
085: applet.setCode(_code);
086: applet.setCodeBase(_codeBase);
087: if (_interactWithForm != null) {
088: if (_interactWithForm.startsWith(_appletdatasource + ":"))
089: applet.setInteractWithForm(_interactWithForm);
090: else
091: applet.setInteractWithForm(BaseTagHelper
092: .stringToBoolean(_interactWithForm, false));
093: }
094: if (_mayScript != null) {
095: if (_mayScript.startsWith(_appletdatasource + ":"))
096: applet.setMayScript(_mayScript);
097: else
098: applet.setMayScript(BaseTagHelper.stringToBoolean(
099: _mayScript, false));
100: }
101: if (_nojavasupport != null)
102: applet.setNoJavaSupport(_nojavasupport);
103: applet.setObject(_object);
104: if (_pluginClassId != null)
105: applet.setPluginClassId(_pluginClassId);
106: if (_pluginCodeBase != null)
107: applet.setPluginCodeBase(_pluginCodeBase);
108: if (_pluginsPage != null)
109: applet.setPluginsPage(_pluginsPage);
110: applet.setState(_state);
111: applet.setTitle(_title);
112: if (_type != null)
113: applet.setType(_type);
114: if (_usePlugin != null)
115: applet.setUsePlugin(BaseTagHelper.stringToBoolean(
116: _usePlugin, false));
117: applet.setValue(_value);
118:
119: return applet;
120: }
121:
122: /**
123: * This method is called when necessary to generate the required html for a tag. It should be overridden by tags that have more Html to generate (generally tags that require several passes to complete). A tag shouldn't generate any Html itself, but should instead delagate that to the Html or JSP component within it.
124: */
125:
126: protected void generateComponentHTML(JspWriter w) throws Exception {
127: super .generateComponentHTML(w);
128: TagContext t = getHelper().getTagContext();
129: if (!t.getDreamWeaverMode() && !t.getRefIndexPrinted()) {
130: w
131: .print("<INPUT TYPE=\"HIDDEN\" NAME=\"Page_refIndex_hidden\" VALUE=\""
132: + getHelper().getController().getRefIndex()
133: + "\">");
134: // Add a transaction token (if present in our session)
135: javax.servlet.http.HttpSession session = getHelper()
136: .getController().getSession();
137: if (session != null) {
138: String token = (String) session
139: .getAttribute(HtmlPage.TRANSACTION_TOKEN_KEY);
140: if (token != null) {
141: w.print("<input type=\"hidden\" name=\""
142: + Constants.TOKEN_KEY + "\" value=\""
143: + token + "\">");
144: }
145: }
146: t.setRefIndexPrinted(true);
147: }
148: }
149:
150: /**
151: * get the tag's align attribute
152: */
153: public String getAlign() {
154: return _align;
155: }
156:
157: /**
158: * get the tag's alt attribute
159: */
160: public String getAlt() {
161: return _alt;
162: }
163:
164: /**
165: * get the tag's appletdatasource attribute
166: */
167: public String getAppletdatasource() {
168: return _appletdatasource;
169: }
170:
171: /**
172: * get the tag's archive attribute
173: */
174: public String getArchive() {
175: return _archive;
176: }
177:
178: /**
179: * get the tag's code attribute
180: */
181: public String getCode() {
182: return _code;
183: }
184:
185: /**
186: * get the tag's codebase attribute
187: */
188: public String getCodebase() {
189: return _codeBase;
190: }
191:
192: /**
193: * Set the tag's wrap attribute
194: */
195:
196: public String getHeight() {
197: return _height;
198: }
199:
200: /**
201: * gets the Hspace
202: */
203: public String getHspace() {
204: return _hspace;
205: }
206:
207: /**
208: * get the tag's interactwithforms attribute
209: */
210: public String getInteractwithform() {
211: return _interactWithForm;
212: }
213:
214: /**
215: * get the tag's mayscript attribute
216: */
217: public String getMayscript() {
218: return _mayScript;
219: }
220:
221: /**
222: * get the tag's nojavasupport attribute
223: */
224: public String getNojavasupport() {
225: return _nojavasupport;
226: }
227:
228: /**
229: * get the tag's object attribute
230: */
231: public String getObject() {
232: return _object;
233: }
234:
235: /**
236: * get the tag's pluginclassid attribute
237: */
238: public String getPluginclassid() {
239: return _pluginClassId;
240: }
241:
242: /**
243: * get the tag's plugincodebase attribute
244: */
245: public String getPlugincodebase() {
246: return _pluginCodeBase;
247: }
248:
249: /**
250: * get the tag's pluginspage attribute
251: */
252: public String getPluginspage() {
253: return _pluginsPage;
254: }
255:
256: /**
257: * get the tag's state attribute
258: */
259: public String getState() {
260: return _state;
261: }
262:
263: /**
264: * get the tag's title attribute
265: */
266: public String getTitle() {
267: return _title;
268: }
269:
270: /**
271: * Returns the type of DreamWeaver conversion that this tag uses.
272: */
273: public int getTagConvertType() {
274: return CONV_WRAP_ALL_NESTED;
275: }
276:
277: /**
278: * Get the tag's type attribute
279: */
280: public String getType() {
281: return _type;
282: }
283:
284: /**
285: * get the tag's useplugin attribute
286: */
287: public String getUseplugin() {
288: return _usePlugin;
289: }
290:
291: /**
292: * Get the tag's value attribute
293: */
294: public String getValue() {
295: return _value;
296: }
297:
298: /**
299: * gets the Vspace
300: */
301: public String getVspace() {
302: return _vspace;
303: }
304:
305: /**
306: * Set the tag's width attribute
307: */
308:
309: public String getWidth() {
310: return _width;
311: }
312:
313: /**
314: * Release all resources used by the tag.
315: */
316: public void release() {
317: super .release();
318: _align = null;
319: _alt = null;
320: _archive = null;
321: _code = null;
322: _codeBase = null;
323: _height = null;
324: _hspace = null;
325: _interactWithForm = null;
326: _mayScript = null;
327: _nojavasupport = null;
328: _object = null;
329: _pluginClassId = null;
330: _pluginCodeBase = null;
331: _pluginsPage = null;
332: _state = null;
333: _title = null;
334: _type = null;
335: _usePlugin = null;
336: _value = null;
337: _vspace = null;
338: _width = null;
339: }
340:
341: /**
342: * Set the tag's align attribute
343: */
344: public void setAlign(String align) {
345: _align = align;
346: }
347:
348: /**
349: * sets the tag's alt attribute
350: */
351: public void setAlt(String alt) {
352: _alt = alt;
353: }
354:
355: /**
356: * set the tag's appletdatasource attribute
357: */
358: public void setAppletdatasource(String sAppletDatasource) {
359: _appletdatasource = sAppletDatasource;
360: }
361:
362: /**
363: * set the tag's archive attribute
364: */
365: public void setArchive(String sArchive) {
366: _archive = sArchive;
367: }
368:
369: /**
370: * set the tag's code attribute
371: */
372: public void setCode(String sCode) {
373: _code = sCode;
374: }
375:
376: /**
377: * set the tag's codebase attribute
378: */
379: public void setCodebase(String sCodebase) {
380: _codeBase = sCodebase;
381: }
382:
383: /**
384: * Set the tag's height attribute
385: */
386:
387: public void setHeight(String val) {
388: _height = val;
389: }
390:
391: /**
392: * sets the Hspace
393: */
394: public void setHspace(String hSpace) {
395: _hspace = hSpace;
396: }
397:
398: /**
399: * set the tag's interactwithforms attribute
400: */
401: public void setInteractwithform(String sInteractWithForms) {
402: _interactWithForm = sInteractWithForms;
403: }
404:
405: /**
406: * set the tag's mayscript attribute
407: */
408: public void setMayscript(String sMayscript) {
409: _mayScript = sMayscript;
410: }
411:
412: /**
413: * set the tag's nojavasupport attribute
414: */
415: public void setNojavasupport(String sNoJavaSupport) {
416: _nojavasupport = sNoJavaSupport;
417: }
418:
419: /**
420: * set the tag's object attribute
421: */
422: public void setObject(String sObject) {
423: _object = sObject;
424: }
425:
426: /**
427: * set the tag's pluginclassid attribute
428: */
429: public void setPluginclassid(String sPluginClassId) {
430: _pluginClassId = sPluginClassId;
431: }
432:
433: /**
434: * set the tag's plugincodebase attribute
435: */
436: public void setPlugincodebase(String sPluginCodebase) {
437: _pluginCodeBase = sPluginCodebase;
438: }
439:
440: /**
441: * set the tag's pluginspage attribute
442: */
443: public void setPluginspage(String sPluginspage) {
444: _pluginsPage = sPluginspage;
445: }
446:
447: /**
448: * set the tag's state attribute
449: */
450: public void setState(String sState) {
451: _state = sState;
452: }
453:
454: /**
455: * set the tag's title attribute
456: */
457: public void setTitle(String sTitle) {
458: _title = sTitle;
459: }
460:
461: /**
462: * Set the tag's type attribute
463: */
464:
465: public void setType(String type) {
466: _type = type;
467: }
468:
469: /**
470: * set the tag's useplugin attribute
471: */
472: public void setUseplugin(String sUseplugin) {
473: _usePlugin = sUseplugin;
474: }
475:
476: /**
477: * Set the tag's value attribute
478: */
479:
480: public void setValue(String value) {
481: _value = value;
482: }
483:
484: /**
485: * sets the Vspace
486: */
487: public void setVspace(String vSpace) {
488: _vspace = vSpace;
489: }
490:
491: /**
492: * Set the tag's width attribute
493: */
494:
495: public void setWidth(String val) {
496: _width = val;
497: }
498:
499: }
|