KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > model > SelectTag


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 the select input tag which will generate
17  * the HTML select tags.
18  *
19  * @author Brian Pontarelli
20  */

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

31     public void initialize() throws JspException JavaDoc {
32
33         // Initialize the parent reference
34
super.initialize();
35         super.initializeKeyProperty();
36
37         modelResolution = ModelHelper.getModelResolution(key, property, pageContext);
38         if (modelResolution == null) {
39             throw new JspException JavaDoc("Invalid model definition: " + getModel());
40         }
41
42         // The only reason that we are allowed to mess with the value property
43
// like this is because the select tag does not ever use the value
44
// property. This is dangerous and must be used carefully.
45
if (isGetValue()) {
46             Object JavaDoc value = ModelHelper.getValue(modelResolution, pageContext);
47             if (value != null) {
48                 localValue = value;
49             }
50         }
51     }
52
53     /**
54      * Outputs the extra model information
55      *
56      * @return Always returns EVAL_PAGE
57      */

58     public int doEndTag() throws JspException JavaDoc {
59         super.doEndTag();
60         if (isSetValue()) {
61             ModelHelper.outputModelExtra(modelResolution.getMetaData(), localName,
62                 pageContext);
63         }
64
65         return EVAL_PAGE;
66     }
67 }
Popular Tags