KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > model > 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.model;
8
9
10 import javax.servlet.jsp.JspException JavaDoc;
11
12 import com.inversoft.verge.mvc.model.ModelResolution;
13
14
15 /**
16  * This class is a basic text input tag for use in a jsp
17  * page. It creates an HTML text input tag and uses the model
18  * objects value for the value of the HTML tag. This also
19  * writes out all the additional information needed for the
20  * server to handle the setting of the model objects value.
21  *
22  * @author Brian Pontarelli
23  */

24 public class TextTag extends com.inversoft.verge.mvc.view.jsp.html.TextTag {
25
26     protected ModelResolution modelResolution;
27
28
29     /**
30      * Initializes the tag by checking that the tag is inside a form tag
31      *
32      * @throws JspException If this tag is not inside a form tag
33      */

34     public void initialize() throws JspException JavaDoc {
35
36         // Initialize the parent reference
37
super.initialize();
38         super.initializeKeyProperty();
39
40         modelResolution = ModelHelper.getModelResolution(key, property, pageContext);
41         if (modelResolution == null) {
42             throw new JspException JavaDoc("Invalid model definition: " + getModel());
43         }
44     }
45
46     /**
47      * Overrides createTextTag and pulls the value from the model object. This
48      * determines which value to use and then calls the super version of that
49      * method.
50      *
51      * @param buf The StringBuffer to appended to
52      * @param name The name of the text tag
53      * @param value The value from the tag
54      * @throws JspException If there was any problems retrieving the model's
55      * value
56      */

57     protected void createTextTag(StringBuffer JavaDoc buf, String JavaDoc id, String JavaDoc name,
58             Object JavaDoc value)
59     throws JspException JavaDoc {
60         if (isGetValue()) {
61             value = ModelHelper.getValue(modelResolution, pageContext);
62         }
63
64         super.createTextTag(buf, id, name, value);
65     }
66
67     /**
68      * Outputs the extra model information
69      *
70      * @return Always returns EVAL_PAGE
71      */

72     public int doEndTag() throws JspException JavaDoc {
73         super.doEndTag();
74         if (isSetValue()) {
75             ModelHelper.outputModelExtra(modelResolution.getMetaData(), localName,
76                 pageContext);
77         }
78
79         return EVAL_PAGE;
80     }
81 }
Popular Tags