Source code: org/apache/struts/taglib/nested/bean/NestedWriteTag.java
1 /*
2 * $Id: NestedWriteTag.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.bean;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.jsp.JspException;
22
23 import org.apache.struts.taglib.bean.WriteTag;
24 import org.apache.struts.taglib.nested.NestedNameSupport;
25 import org.apache.struts.taglib.nested.NestedPropertyHelper;
26
27 /**
28 * NestedWriteTag.
29 * @since Struts 1.1
30 * @version $Rev: 54929 $ $Date: 2004-10-16 09:38:42 -0700 (Sat, 16 Oct 2004) $
31 */
32 public class NestedWriteTag extends WriteTag implements NestedNameSupport {
33
34 /**
35 * Overriding method of the heart of the matter. Gets the relative property
36 * and leaves the rest up to the original tag implementation. Sweet.
37 * @return int JSP continuation directive.
38 * This is in the hands of the super class.
39 */
40 public int doStartTag() throws JspException {
41 // get the original properties
42 originalName = getName();
43 originalProperty = getProperty();
44
45 // request
46 HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
47 // set the properties
48 NestedPropertyHelper.setNestedProperties(request, this);
49
50 // let the super do it's thing
51 return super.doStartTag();
52 }
53
54 /**
55 * Complete the processing of the tag. The nested tags here will restore
56 * all the original value for the tag itself and the nesting context.
57 * @return int to describe the next step for the JSP processor
58 * @throws JspException for the bad things JSP's do
59 */
60 public int doEndTag() throws JspException {
61 // do the super's ending part
62 int i = super.doEndTag();
63
64 // reset the properties
65 setName(originalName);
66 setProperty(originalProperty);
67
68 // continue
69 return i;
70 }
71
72 /**
73 * Release the tag's resources and reset the values.
74 */
75 public void release() {
76 super.release();
77 // reset the originals
78 originalName = null;
79 originalProperty = null;
80 }
81
82 /* the usual private member variables */
83 private String originalName = null;
84 private String originalProperty = null;
85 }