KickJava   Java API By Example, From Geeks To Geeks.

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


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.verge.mvc.view.HtmlViewToolkit;
17
18
19 /**
20  * This class generates a simple submit tag. This tag must
21  * be embedded in a form tag (custom form tag in this
22  * package).
23  *
24  * @author Brian Pontarelli
25  */

26 public class SubmitTag extends BaseControllerTag {
27
28     /**
29      * This classes logger
30      */

31     private static final Logger logger = Logger.getLogger(SubmitTag.class);
32
33
34     /**
35      * Creates an HTML submit tag. This is constructed using the value attribute
36      * and the bean attribute. The bean attribute uses dot notation to signify
37      * what bean to use and what method to call. The bean to use is a simple name
38      * setup using an include tag. The method to call is the JavaBean name for
39      * the handler method. ie foo corresponds to handleFoo.
40      *
41      * @return Always returns SKIP_BODY
42      * @throws JspException If this tag is not in a form tag, the bean was not
43      * included or the bean attribute doesn't specify a handler name
44      */

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

76     protected void createSubmitTag(StringBuffer JavaDoc buf, String JavaDoc id, String JavaDoc name,
77             Object JavaDoc value) {
78         String JavaDoc valueStr = (value == null) ? null : value.toString();
79         HtmlViewToolkit.createSubmitTag(buf, id, name, valueStr,
80             attributes, singleAttrs);
81     }
82 }
Popular Tags