KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > nested > html > NestedFormTag


1 /*
2  * $Id: NestedFormTag.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.struts.taglib.nested.html;
19
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import javax.servlet.jsp.JspException JavaDoc;
22
23 import org.apache.struts.taglib.html.FormTag;
24 import org.apache.struts.taglib.nested.NestedNameSupport;
25 import org.apache.struts.taglib.nested.NestedPropertyHelper;
26
27 /**
28  * NestedFormTag.
29  * @since Struts 1.1
30  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
31  */

32 public class NestedFormTag extends FormTag implements NestedNameSupport {
33
34
35     //TODO: name property was removed from FormTag but appears to be required
36
// for the nested version to work. See if it can be removed
37
// from here altogether.
38
/**
39      * The name
40      */

41     protected String JavaDoc name = null;
42
43     /**
44      * Return the name.
45      */

46     public String JavaDoc getName() {
47
48         return (this.name);
49
50     }
51
52     /**
53      * Set the name.
54      *
55      * @param name The new name
56      */

57     public void setName(String JavaDoc name) {
58
59         this.name = name;
60
61     }
62
63
64   /**
65    * Get the string value of the "property" property.
66    * @return the property property
67    */

68   public String JavaDoc getProperty() {
69     return "";
70   }
71
72   /**
73    * Setter for the "property" property
74    * @param newProperty new value for the property
75    */

76   public void setProperty(String JavaDoc newProperty) {}
77
78
79   /**
80    * Overriding to allow the chance to set the details of the system, so that
81    * dynamic includes can be possible
82    * @return int JSP continuation directive.
83    */

84   public int doStartTag() throws JspException JavaDoc {
85     // store original result
86
int temp = super.doStartTag();
87
88     HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc)pageContext.getRequest();
89     // original nesting details
90
originalNesting = NestedPropertyHelper.getCurrentProperty(request);
91     originalNestingName = NestedPropertyHelper.getCurrentName(request, this);
92
93     // some new details
94
NestedPropertyHelper.setProperty(request, null);
95     NestedPropertyHelper.setName(request, super.getBeanName());
96
97     // continue
98
return temp;
99   }
100
101   /**
102    * This is only overriden to clean up the include reference
103    * @return int JSP continuation directive.
104    */

105   public int doEndTag() throws JspException JavaDoc {
106     // super result
107
int temp = super.doEndTag();
108
109     // all done. clean up
110
HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc)pageContext.getRequest();
111     // reset the original nesting values
112
if (originalNesting == null) {
113       NestedPropertyHelper.deleteReference(request);
114     } else {
115       NestedPropertyHelper.setProperty(request, originalNesting);
116       NestedPropertyHelper.setName(request, originalNestingName);
117     }
118
119     // return the super result
120
return temp;
121   }
122
123   /**
124    * Release the tag's resources and reset the values.
125    */

126   public void release() {
127     // let the super release
128
super.release();
129     // reset the original value place holders
130
originalNesting = null;
131     originalNestingName = null;
132   }
133
134   // original nesting environment
135
private String JavaDoc originalNesting = null;
136   private String JavaDoc originalNestingName = null;
137 }
138
Popular Tags