KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: NestedOptionsTag.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.Constants;
24 import org.apache.struts.taglib.html.OptionsTag;
25 import org.apache.struts.taglib.nested.NestedNameSupport;
26 import org.apache.struts.taglib.nested.NestedPropertyHelper;
27
28 /**
29  * NestedOptionsTag.
30  * @since Struts 1.1
31  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
32  */

33 public class NestedOptionsTag extends OptionsTag implements NestedNameSupport {
34
35   /**
36    * Overriding method of the heart of the matter. Gets the relative property
37    * and leaves the rest up to the original tag implementation. Sweet.
38    * @return int JSP continuation directive.
39    * This is in the hands of the super class.
40    */

41   public int doStartTag() throws JspException JavaDoc {
42     // get the original properties
43
originalName = getName();
44     originalProperty = getProperty();
45     originalLabelProperty = getLabelProperty();
46
47     // request
48
HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc)pageContext.getRequest();
49
50     // if we have a label property
51
if (originalLabelProperty != null) {
52       // do the label property first
53
if (getName() == null|| Constants.BEAN_KEY.equals(getName())) {
54         super.setLabelProperty(NestedPropertyHelper.getAdjustedProperty(request,
55                                                          originalLabelProperty));
56       } else {
57           super.setLabelProperty(originalLabelProperty);
58       }
59     }
60
61     // set the other properties
62
NestedPropertyHelper.setNestedProperties(request, this);
63
64
65
66     // let the super do it's thing
67
return super.doStartTag();
68   }
69
70   /**
71    * Complete the processing of the tag. The nested tags here will restore
72    * all the original value for the tag itself and the nesting context.
73    * @return int to describe the next step for the JSP processor
74    * @throws JspException for the bad things JSP's do
75    */

76   public int doEndTag() throws JspException JavaDoc {
77     // do the super's ending part
78
int i = super.doEndTag();
79
80     // reset the properties
81
setName(originalName);
82     setProperty(originalProperty);
83     setLabelProperty(originalLabelProperty);
84
85     // continue
86
return i;
87   }
88
89   /**
90    * Release the tag's resources and reset the values.
91    */

92   public void release() {
93     super.release();
94     // reset the originals
95
originalName = null;
96     originalProperty = null;
97     originalLabelProperty = null;
98   }
99
100   /* the usual private member variables */
101   private String JavaDoc originalName = null;
102   private String JavaDoc originalProperty = null;
103   private String JavaDoc originalLabelProperty = null;
104 }
105
Popular Tags