Coverage details for org.chwf.taglib.jhtml.LabelTag

LineHitsSource
1 /*
2 Chrysalis Web Framework [http://chrysalis.sourceforge.net]
3 Copyright (c) 2002, 2003, 2004, Paul Strack
4  
5 All rights reserved.
6  
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9  
10 1. Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12  
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16  
17 3. Neither the name of the copyright holder nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20  
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32  
33 package org.chwf.taglib.jhtml;
34  
35 import java.io.IOException;
36  
37 import javax.servlet.jsp.JspException;
38 import javax.servlet.jsp.JspWriter;
39  
40 /**
41  * Tag handler for the <code>&lt;label&gt;</code> tag.
42  *
43  * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a>
44  */
4514public class LabelTag extends FieldTagSupport {
46  
47   /** The field that this label is for. */
48   private String forField;
49  
50   /**
51    * Clean up data for tag handler reuse and pooling. Should be overridden in
52    * tag handler. Subclasses should always invoke their superclass's cleanup
53    * method: <code>super.cleanup()</code>
54    */
55   public void cleanup() {
561    super.cleanup();
571    this.forField = null;
581  }
59  
60   /**
61    * Calls superclass method. Is present here because of a bug in some servlet
62    * engines that requires tag attibute setters to be defined in the tag class
63    * itself.
64    *
65    * @param objectName The object name.
66    * @throws JspException For errors.
67    */
68   public void setObject(String objectName) throws JspException {
690    super.setObject(objectName);
700  }
71  
72   /**
73    * Calls superclass method. Is present here because of a bug in some servlet
74    * engines that requires tag attibute setters to be defined in the tag class
75    * itself.
76    *
77    * @param property The property name.
78    * @throws JspException For errors.
79    */
80   public void setProperty(String property) throws JspException {
814    super.setProperty(property);
824  }
83  
84   /**
85    * The form field name. Defaults to the property value if absent. Effectively
86    * equivalent to the "name" attribute.
87    *
88    * @param value The field name.
89    */
90   public void setFor(String value) {
912    setName(value);
922  }
93  
94   /**
95    * The form field name. Defaults to the property value if absent. Effectively
96    * equivalent to the "name" attribute.
97    *
98    * @return The field name.
99    */
100   public String getFor() {
1016    return getName();
102   }
103  
104   /**
105    * Pass-through attribute. Same meaning as in HTML.
106    *
107    * @param value The attribute value.
108    */
109   public void setAccesskey(String value) {
1101    addAttribute("accesskey", value);
1111  }
112  
113   /**
114    * Print the property's label using BeanFilter metadata.
115    *
116    * @return SKIP_BODY.
117    * @throws IOException For write errors.
118    * @throws JspException If the property cannot be initialized.
119    */
120   public int doStart() throws IOException, JspException {
1212    printLabel();
1222    return SKIP_BODY;
123   }
124  
125   /**
126    * Print the field label.
127    *
128    * @throws IOException For write errors.
129    * @throws JspException If object not defined.
130    */
131   private void printLabel() throws IOException, JspException {
1322    JspWriter out = pageContext.getOut();
1332    out.print("<label for='");
1342    out.print(getFor());
1352    out.print("'");
1362    printAttributes();
1372    out.print(">");
1382    out.print(deriveLabel());
1392    out.print("</label>");
1402  }
141  
142   /**
143    * Pass-through attribute. Same meaning as "class" in HTML.
144    *
145    * @param value The attribute value.
146    */
147   public void setStyleClass(String value) {
1481    addAttribute("class", value);
1491  }
150  
151   /**
152    * Pass-through attribute. Same meaning as in HTML.
153    *
154    * @param value The attribute value.
155    */
156   public void setId(String value) {
1571    addAttribute("id", value);
1581  }
159  
160   /**
161    * Pass-through attribute. Same meaning as in HTML.
162    *
163    * @param value The attribute value.
164    */
165   public void setLang(String value) {
1661    addAttribute("lang", value);
1671  }
168  
169   /**
170    * Pass-through attribute. Same meaning as in HTML.
171    *
172    * @param value The attribute value.
173    */
174   public void setStyle(String value) {
1751    addAttribute("style", value);
1761  }
177  
178   /**
179    * Pass-through attribute. Same meaning as in HTML.
180    *
181    * @param value The attribute value.
182    */
183   public void setTitle(String value) {
1841    addAttribute("title", value);
1851  }
186 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.