001: //** Copyright Statement ***************************************************
002: // Licensed Material - Property of Salmon LLC
003: // (C) Copyright Salmon LLC. 1999 - All Rights Reserved
004: // For more information go to www.salmonllc.com
005: //
006: // *************************************************************************
007: // DISCLAIMER:
008: // The following code has been created by Salmon LLC. The code is provided
009: // 'AS IS' , without warranty of any kind unless covered in another agreement
010: // between your corporation and Salmon LLC. Salmon LLC shall not be liable
011: // for any damages arising out of your use of this, even if they have been
012: // advised of the possibility of such damages.
013: //** End Copyright Statement ***************************************************
014: package com.salmonllc.wml.tags;
015:
016: ////////////////////////////////////////////////////////////
017: //$Archive: /SOFIA/SourceCode/com/salmonllc/wml/tags/InputTag.java $
018: //$Author: Srufle $
019: //$Revision: 5 $
020: //$Modtime: 4/15/03 10:25a $
021: ////////////////////////////////////////////////////////////
022:
023: import com.salmonllc.html.HtmlComponent;
024: import com.salmonllc.jsp.tags.BaseEmptyTag;
025: import com.salmonllc.jsp.tags.BaseTagHelper;
026: import com.salmonllc.wml.WmlPasswordEdit;
027: import com.salmonllc.wml.WmlTextEdit;
028:
029: /**
030: * This tag approximately corresponds to the WML tag "INPUT"
031: */
032:
033: public class InputTag extends BaseEmptyTag {
034:
035: private String _enabled;
036:
037: private String _maxLength;
038: private String _size;
039:
040: private String _type;
041:
042: private String _value;
043:
044: private String _dataSource;
045: private String _class;
046: private String _format;
047: private String _emptyok;
048: private String _tabindex;
049: private String _title;
050:
051: /**
052: * Creates the component to be used by the tag.
053: */
054: public HtmlComponent createComponent() {
055: if (_type == null)
056: return null;
057:
058: String type = _type.toUpperCase();
059: if (type.equals("PASSWORD")) {
060: WmlPasswordEdit pass = new WmlPasswordEdit(getName(),
061: getHelper().getController());
062: pass.setSize(BaseTagHelper.stringToInt(_size, 0));
063: pass.setMaxLength(BaseTagHelper.stringToInt(_maxLength, 0));
064: pass.setValue(_value);
065: pass.setVisible(BaseTagHelper.stringToBoolean(getVisible(),
066: true));
067: if (_dataSource != null)
068: pass.setDataSource(_dataSource);
069: pass.setClassName(_class);
070: pass.setFormat(_format);
071: pass.setEmptyOk(BaseTagHelper.stringToBoolean(_emptyok,
072: false));
073: pass.setTabIndex(BaseTagHelper.stringToInt(_tabindex));
074: pass.setTitle(_title);
075: CardTag cTag = (CardTag) findAncestorWithClass(this ,
076: CardTag.class);
077: cTag.getCard().addInputComponent(pass);
078: return pass;
079: } else if (type.equals("TEXT")) {
080: WmlTextEdit edit = new WmlTextEdit(getName(), getHelper()
081: .getController());
082: edit.setSize(BaseTagHelper.stringToInt(_size));
083: edit.setMaxLength(BaseTagHelper.stringToInt(_maxLength));
084: edit.setValue(_value);
085: edit.setVisible(BaseTagHelper.stringToBoolean(getVisible(),
086: true));
087: if (_dataSource != null)
088: edit.setDataSource(_dataSource);
089:
090: edit.setClassName(_class);
091: edit.setFormat(_format);
092: edit.setEmptyOk(BaseTagHelper.stringToBoolean(_emptyok,
093: false));
094: edit.setTabIndex(BaseTagHelper.stringToInt(_tabindex));
095: edit.setTitle(_title);
096: CardTag cTag = (CardTag) findAncestorWithClass(this ,
097: CardTag.class);
098: cTag.getCard().addInputComponent(edit);
099: return edit;
100: }
101: return null;
102: }
103:
104: /**
105: * get the tag's classname attribute
106: */
107: public String getClassname() {
108: return _class;
109: }
110:
111: /**
112: * Get the Data Source the component should be bound to
113: */
114: public String getDatasource() {
115: return _dataSource;
116: }
117:
118: /**
119: * get the tag's enabled attribute
120: */
121: public String getEnabled() {
122: return _enabled;
123: }
124:
125: /**
126: * Returns the length of the field
127: */
128: public String getLength() {
129: return _maxLength;
130: }
131:
132: /**
133: * Set the tag's maxlength attribute
134: */
135: public String getMaxlength() {
136: return _maxLength;
137: }
138:
139: /**
140: * Get the tag's type attribute
141: */
142: public String getType() {
143: return _type;
144: }
145:
146: /**
147: * Get the tag's value attribute
148: */
149: public String getValue() {
150: return _value;
151: }
152:
153: /**
154: * Get the tag's format attribute
155: */
156: public String getFormat() {
157: return _format;
158: }
159:
160: /**
161: * Get the tag's emptyok attribute
162: */
163: public String getEmptyok() {
164: return _emptyok;
165: }
166:
167: /**
168: * Get the tag's tabindex attribute
169: */
170: public String getTabindex() {
171: return _tabindex;
172: }
173:
174: /**
175: * Get the tag's title attribute
176: */
177: public String getTitle() {
178: return _title;
179: }
180:
181: /**
182: * Release all resources used by the tag.
183: */
184: public void release() {
185: super .release();
186: _maxLength = null;
187: _size = null;
188: _type = null;
189: _value = null;
190: _emptyok = null;
191: _format = null;
192: _dataSource = null;
193: _tabindex = null;
194: _class = null;
195: _dataSource = null;
196: _enabled = null;
197: _size = null;
198: _title = null;
199: }
200:
201: /**
202: * Set the tag's classname attribute
203: */
204: public void setClassname(String sClass) {
205: _class = sClass;
206: }
207:
208: /**
209: * Set the Data Source the component should be bound to
210: */
211: public void setDatasource(String val) {
212: _dataSource = val;
213: }
214:
215: /**
216: * Set the tag's enabled attribute
217: */
218: public void setEnabled(String val) {
219: _enabled = val;
220: }
221:
222: /**
223: * Sets the length of the field
224: */
225: public void setLength(String newLength) {
226: _maxLength = newLength;
227: }
228:
229: /**
230: * Set the tag's maxLength attribute
231: */
232: public void setMaxlength(String maxLength) {
233: _maxLength = maxLength;
234: }
235:
236: /**
237: * Set the tag's size attribute
238: */
239: public void setSize(String size) {
240: _size = size;
241: }
242:
243: /**
244: * Set the tag's type attribute
245: */
246:
247: public void setType(String type) {
248: _type = type;
249: }
250:
251: /**
252: * Set the tag's value attribute
253: */
254:
255: public void setValue(String value) {
256: _value = value;
257: }
258:
259: /**
260: * Set the tag's format attribute
261: */
262:
263: public void setFormat(String _format) {
264: this ._format = _format;
265: }
266:
267: /**
268: * Set the tag's emptyok attribute
269: */
270: public void setEmptyok(String _emptyok) {
271: this ._emptyok = _emptyok;
272: }
273:
274: /**
275: * Set the tag's tabindex attribute
276: */
277: public void setTabindex(String _tabindex) {
278: this ._tabindex = _tabindex;
279: }
280:
281: /**
282: * Set the tag's title attribute
283: */
284: public void setTitle(String _title) {
285: this._title = _title;
286: }
287:
288: }
|