KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > html > TextTag


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.view.jsp.html;
8
9
10 import java.io.IOException JavaDoc;
11
12 import javax.servlet.jsp.JspException JavaDoc;
13
14 import org.apache.log4j.Logger;
15
16 import com.inversoft.util.ObjectTools;
17 import com.inversoft.verge.mvc.view.HtmlViewToolkit;
18
19
20 /**
21  * This class is a basic text input tag for use in a jsp
22  * page. It creates an HTML text input tag.
23  *
24  * @author Brian Pontarelli
25  */

26 public class TextTag extends InputTag {
27
28     /**
29      * This classes logger
30      */

31     private static final Logger logger = Logger.getLogger(TextTag.class);
32
33
34     /**
35      * Ouputs a text input tag.
36      *
37      * @return Always returns SKIP_BODY
38      * @throws JspException If there was any problem outputting the input tag
39      */

40     public int doStartTag() throws JspException JavaDoc {
41
42         // Initialize the parent reference and the bean reference for model
43
// sub-classes
44
initialize();
45
46         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
47         createTextTag(buf, getId(), localName, localValue);
48
49         if (logger.isDebugEnabled()) {
50             logger.debug("The text tag: " + buf.toString());
51             logger.debug("id: " + toString());
52         }
53
54         try {
55             pageContext.getOut().print(buf.toString());
56         } catch (IOException JavaDoc ioe) {
57             throw new JspException JavaDoc(ioe.toString());
58         }
59
60         return SKIP_BODY;
61     }
62
63     /**
64      * Does the work of creating the tags body. This method can be overridden
65      * in sub-classes to change the attributes that are appended, etc. By default
66      * this creates a text tag with the name, value, attributes (single and named)
67      *
68      * @param buf The StringBuffer to append to
69      * @param name The name of the input tag
70      * @param value The value to use for the text tag
71      */

72     protected void createTextTag(StringBuffer JavaDoc buf, String JavaDoc id, String JavaDoc name,
73             Object JavaDoc value)
74     throws JspException JavaDoc {
75         String JavaDoc valueStr = ObjectTools.toString(value);
76         HtmlViewToolkit.createTextTag(buf, id, name, valueStr, attributes,
77             singleAttrs);
78     }
79 }
Popular Tags