View Javadoc

1   /*
2    * $Id: ImageTag.java 130 2004-11-28 13:00:44Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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      // Fields
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      // Constructors
45      /**
46       * Creates a new <code>ImageTag</code> object.
47       */
48      public ImageTag() {
49          super("image");
50      }
51  
52      // Renderer
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      // Attributes
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 }