KickJava   Java API By Example, From Geeks To Geeks.

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


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 hidden input tag for use in a jsp
22  * page. It creates an HTML hidden input tag.
23  *
24  * @author Brian Pontarelli
25  */

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

31     private static final Logger logger = Logger.getLogger(HiddenTag.class);
32
33
34     /**
35      * Ouputs a hidden 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         createHiddenTag(buf, id, localName, localValue);
48
49         if (logger.isDebugEnabled()) {
50             logger.debug("The hidden 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 hidden tag with the name, value, attributes (single and named)
67      *
68      * @param buf The StringBuffer to append to
69      * @param value The value to use for the hidden tag
70      */

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