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 /**
26 * Implementation of input type image form control tag.
27 *
28 * @author Jose M. Palomar
29 * @version $Revision: 130 $
30 */
31 public final class ImageTag extends InputTag {
32
33
34 /**
35 * <code>src</code> attribute.
36 */
37 private String src;
38
39 /**
40 * <code>alt</code> attribute.
41 */
42 private String alt;
43
44
45 /**
46 * Creates a new <code>ImageTag</code> object.
47 */
48 public ImageTag() {
49 super("image");
50 }
51
52
53 /**
54 * Renders a string with values of input attributes.<br>
55 * Input attributes for image are <code>src</code> and <code>alt</code>.
56 *
57 * @return String a string with values of input attributes.
58 */
59 public String inputAttributes() {
60
61 StringBuffer atts = new StringBuffer();
62
63 if (src != null) {
64 atts.append(" src=\"");
65 atts.append(src);
66 atts.append("\"");
67 }
68
69 if (alt != null) {
70 atts.append(" alt=\"");
71 atts.append(alt);
72 atts.append("\"");
73 }
74
75 return atts.toString();
76
77 }
78
79
80 /**
81 * Sets <code>alt</code> attribute value.
82 *
83 * @param alt String <code>alt</code> attribute value.
84 */
85 public void setAlt(String alt) {
86 this.alt = alt;
87 }
88
89 /**
90 * Sets <code>src</code> attribute value.
91 *
92 * @param src String <code>src</code> attribute value.
93 */
94 public void setSrc(String src) {
95 this.src = src;
96 }
97
98 /**
99 * Called on a Tag handler to release state.
100 *
101 * @see javax.servlet.jsp.tagext.Tag#release()
102 */
103 public void release() {
104
105 super.release();
106
107 this.src = null;
108 this.alt = null;
109
110 }
111
112 }