View Javadoc

1   /*
2    * $Id: RadioTag.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 radio form control tag.
27   *
28   * @author  Jose M. Palomar
29   * @version $Revision: 130 $
30   */
31  public final class RadioTag extends InputTag {
32  
33      // Fields
34      /**
35       * <code>checked</code> attribute.
36       */
37      private boolean checked;
38  
39      // Constructors
40      /**
41       * Creates a new <code>RadioTag</code> object.
42       */
43      public RadioTag() {
44          super("radio");
45      }
46  
47      // Renderer
48      /**
49       * Renders a string with values of input attributes.<br>
50       * Input attribute for radio is <code>checked</code>.
51       *
52       * @return String a string with values of input attributes.
53       */
54      public String inputAttributes() {
55  
56          StringBuffer atts = new StringBuffer();
57  
58          if (checked) {
59              atts.append(" checked");
60          }
61  
62          return atts.toString();
63  
64      }
65  
66      // Attributes
67      /**
68       * Sets <code>checked</code> attribute value.
69       *
70       * @param checked String <code>checked</code> attribute value.
71       */
72      public void setChecked(String checked) {
73          this.checked = checked.equals("true");
74      }
75  
76      /**
77       * Called on a Tag handler to release state.
78       *
79       * @see javax.servlet.jsp.tagext.Tag#release()
80       */
81      public void release() {
82  
83          super.release();
84  
85          this.checked = false;
86  
87      }
88  
89  }