View Javadoc

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