1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.taglib.form;
24
25 import javax.servlet.jsp.JspException;
26 import javax.servlet.jsp.tagext.TagSupport;
27
28 /**
29 * Base implementation for all html tags.
30 *
31 * @author Jose M. Palomar
32 * @version $Revision: 130 $
33 */
34 public abstract class BaseTag extends TagSupport {
35
36
37 /**
38 * <code>id</code> attribute.
39 */
40 private String id;
41
42 /**
43 * <code>style</code> attribute.
44 */
45 private String style;
46
47 /**
48 * <code>onclick</code> attribute.
49 */
50 private String onclick;
51
52 /**
53 * <code>ondblclick</code> attribute.
54 */
55 private String ondblclick;
56
57 /**
58 * <code>onmousedown</code> attribute.
59 */
60 private String onmousedown;
61
62 /**
63 * <code>onmouseup</code> attribute.
64 */
65 private String onmouseup;
66
67 /**
68 * <code>onmouseover</code> attribute.
69 */
70 private String onmouseover;
71
72 /**
73 * <code>onmousemove</code> attribute.
74 */
75 private String onmousemove;
76
77 /**
78 * <code>onmouseout</code> attribute.
79 */
80 private String onmouseout;
81
82 /**
83 * <code>onkeypress</code> attribute.
84 */
85 private String onkeypress;
86
87 /**
88 * <code>onkeydown</code> attribute.
89 */
90 private String onkeydown;
91
92 /**
93 * <code>onkeyup</code> attribute.
94 */
95 private String onkeyup;
96
97
98 /**
99 * Creates a new <code>BaseTag</code> object.
100 */
101 protected BaseTag() {
102 }
103
104
105 /**
106 * Process the start tag for this instance.
107 *
108 * @return int EVAL_BODY_INCLUDE.
109 * @throws JspException if somethign goes wrong during processing.
110 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
111 */
112 public int doStartTag() throws JspException {
113 return EVAL_BODY_INCLUDE;
114 }
115
116 /**
117 * Process the end tag for this instance.
118 *
119 * @return int EVAL_PAGE.
120 * @throws JspException if somethign goes wrong during processing.
121 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
122 */
123 public int doEndTag() throws JspException {
124 return EVAL_PAGE;
125 }
126
127
128 /**
129 * Renders a string with values of base attributes.<br>
130 * Base attributes are <code>id</code> and <code>style</code>.
131 *
132 * @return String a string with values of base attributes.
133 */
134 protected final String baseAttributes() {
135
136 StringBuffer atts = new StringBuffer();
137
138 if (id != null) {
139 atts.append(" id=\"");
140 atts.append(id);
141 atts.append("\"");
142 }
143
144 if (style != null) {
145 atts.append(" style=\"");
146 atts.append(style);
147 atts.append("\"");
148 }
149
150 return atts.toString();
151
152 }
153
154 /**
155 * Renders a string with values of intrinsic events attributes.<br>
156 * Intrinsic events attributes are all <code>onmouse*</code> and <code>onkey*</code>
157 * attributes.
158 *
159 * @return String a string with values of intrinsic events attributes.
160 */
161 protected final String intrinsicEvents() {
162
163 StringBuffer events = new StringBuffer();
164
165 if (onclick != null) {
166 events.append(" onclick=\"");
167 events.append(onclick);
168 events.append("\"");
169 }
170
171 if (ondblclick != null) {
172 events.append(" ondblclick=\"");
173 events.append(ondblclick);
174 events.append("\"");
175 }
176
177 if (onkeydown != null) {
178 events.append(" onkeydown=\"");
179 events.append(onkeydown);
180 events.append("\"");
181 }
182
183 if (onkeypress != null) {
184 events.append(" onkeypress=\"");
185 events.append(onkeypress);
186 events.append("\"");
187 }
188
189 if (onkeyup != null) {
190 events.append(" onkeyup=\"");
191 events.append(onkeyup);
192 events.append("\"");
193 }
194
195 if (onmousedown != null) {
196 events.append(" onmousedown=\"");
197 events.append(onmousedown);
198 events.append("\"");
199 }
200
201 if (onmousemove != null) {
202 events.append(" onmousemove=\"");
203 events.append(onmousemove);
204 events.append("\"");
205 }
206
207 if (onmouseout != null) {
208 events.append(" onmouseout=\"");
209 events.append(onmouseout);
210 events.append("\"");
211 }
212
213 if (onmouseover != null) {
214 events.append(" onmouseover=\"");
215 events.append(onmouseover);
216 events.append("\"");
217 }
218
219 if (onmouseup != null) {
220 events.append(" onmouseup=\"");
221 events.append(onmouseup);
222 events.append("\"");
223 }
224
225 return events.toString();
226
227 }
228
229
230 /**
231 * Sets <code>id</code> attribute value.
232 *
233 * @param id String <code>id</code> attribute value.
234 */
235 public final void setId(String id) {
236 this.id = id;
237 }
238
239 /**
240 * Sets <code>style</code> attribute value.
241 *
242 * @param style String <code>style</code> attribute value.
243 */
244 public final void setStyle(String style) {
245 this.style = style;
246 }
247
248 /**
249 * Sets <code>onclick</code> attribute value.
250 *
251 * @param onclick String <code>onclick</code> attribute value.
252 */
253 public final void setOnclick(String onclick) {
254 this.onclick = onclick;
255 }
256
257 /**
258 * Sets <code>ondblclick</code> attribute value.
259 *
260 * @param ondblclick String <code>ondblclick</code> attribute value.
261 */
262 public final void setOndblclick(String ondblclick) {
263 this.ondblclick = ondblclick;
264 }
265
266 /**
267 * Sets <code>onkeydown</code> attribute value.
268 *
269 * @param onkeydown String <code>onkeydown</code> attribute value.
270 */
271 public final void setOnkeydown(String onkeydown) {
272 this.onkeydown = onkeydown;
273 }
274
275 /**
276 * Sets <code>onkeypress</code> attribute value.
277 *
278 * @param onkeypress String <code>onkeypress</code> attribute value.
279 */
280 public final void setOnkeypress(String onkeypress) {
281 this.onkeypress = onkeypress;
282 }
283
284 /**
285 * Sets <code>onkeyup</code> attribute value.
286 *
287 * @param onkeyup String <code>onkeyup</code> attribute value.
288 */
289 public final void setOnkeyup(String onkeyup) {
290 this.onkeyup = onkeyup;
291 }
292
293 /**
294 * Sets <code>onmousedown</code> attribute value.
295 *
296 * @param onmousedown String <code>onmousedown</code> attribute value.
297 */
298 public final void setOnmousedown(String onmousedown) {
299 this.onmousedown = onmousedown;
300 }
301
302 /**
303 * Sets <code>onmousemove</code> attribute value.
304 *
305 * @param onmousemove String <code>onmousemove</code> attribute value.
306 */
307 public final void setOnmousemove(String onmousemove) {
308 this.onmousemove = onmousemove;
309 }
310
311 /**
312 * Sets <code>onmouseout</code> attribute value.
313 *
314 * @param onmouseout String <code>onmouseout</code> attribute value.
315 */
316 public final void setOnmouseout(String onmouseout) {
317 this.onmouseout = onmouseout;
318 }
319
320 /**
321 * Sets <code>onmouseover</code> attribute value.
322 *
323 * @param onmouseover String <code>onmouseover</code> attribute value.
324 */
325 public final void setOnmouseover(String onmouseover) {
326 this.onmouseover = onmouseover;
327 }
328
329 /**
330 * Sets <code>onmouseup</code> attribute value.
331 *
332 * @param onmouseup String <code>onmouseup</code> attribute value.
333 */
334 public final void setOnmouseup(String onmouseup) {
335 this.onmouseup = onmouseup;
336 }
337
338 /**
339 * Called on a Tag handler to release state.
340 *
341 * @see javax.servlet.jsp.tagext.Tag#release()
342 */
343 public void release() {
344
345 super.release();
346
347 this.id = null;
348 this.style = null;
349
350 this.onclick = null;
351 this.ondblclick = null;
352 this.onkeydown = null;
353 this.onkeypress = null;
354 this.onkeyup = null;
355 this.onmousedown = null;
356 this.onmousemove = null;
357 this.onmouseout = null;
358 this.onmouseover = null;
359 this.onmouseup = null;
360
361 }
362
363 }