001: /*
002: * $Id: NestedFormTag.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.taglib.nested.html;
022:
023: import org.apache.struts.taglib.html.FormTag;
024: import org.apache.struts.taglib.nested.NestedNameSupport;
025: import org.apache.struts.taglib.nested.NestedPropertyHelper;
026:
027: import javax.servlet.http.HttpServletRequest;
028: import javax.servlet.jsp.JspException;
029:
030: /**
031: * NestedFormTag.
032: *
033: * @version $Rev: 471754 $ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
034: * $
035: * @since Struts 1.1
036: */
037: public class NestedFormTag extends FormTag implements NestedNameSupport {
038: //TODO: name property was removed from FormTag but appears to be required
039: // for the nested version to work. See if it can be removed
040: // from here altogether.
041:
042: /**
043: * The name
044: */
045: protected String name = null;
046:
047: // original nesting environment
048: private String originalNesting = null;
049: private String originalNestingName = null;
050:
051: /**
052: * Return the name.
053: */
054: public String getName() {
055: return (this .name);
056: }
057:
058: /**
059: * Set the name.
060: *
061: * @param name The new name
062: */
063: public void setName(String name) {
064: this .name = name;
065: }
066:
067: /**
068: * Get the string value of the "property" property.
069: *
070: * @return the property property
071: */
072: public String getProperty() {
073: return "";
074: }
075:
076: /**
077: * Setter for the "property" property
078: *
079: * @param newProperty new value for the property
080: */
081: public void setProperty(String newProperty) {
082: }
083:
084: /**
085: * Overriding to allow the chance to set the details of the system, so
086: * that dynamic includes can be possible
087: *
088: * @return int JSP continuation directive.
089: */
090: public int doStartTag() throws JspException {
091: // store original result
092: int temp = super .doStartTag();
093:
094: HttpServletRequest request = (HttpServletRequest) pageContext
095: .getRequest();
096:
097: // original nesting details
098: originalNesting = NestedPropertyHelper
099: .getCurrentProperty(request);
100: originalNestingName = NestedPropertyHelper.getCurrentName(
101: request, this );
102:
103: // some new details
104: NestedPropertyHelper.setProperty(request, null);
105: NestedPropertyHelper.setName(request, super .getBeanName());
106:
107: // continue
108: return temp;
109: }
110:
111: /**
112: * This is only overriden to clean up the include reference
113: *
114: * @return int JSP continuation directive.
115: */
116: public int doEndTag() throws JspException {
117: // super result
118: int temp = super .doEndTag();
119:
120: // all done. clean up
121: HttpServletRequest request = (HttpServletRequest) pageContext
122: .getRequest();
123:
124: // reset the original nesting values
125: if (originalNesting == null) {
126: NestedPropertyHelper.deleteReference(request);
127: } else {
128: NestedPropertyHelper.setProperty(request, originalNesting);
129: NestedPropertyHelper.setName(request, originalNestingName);
130: }
131:
132: // return the super result
133: return temp;
134: }
135:
136: /**
137: * Release the tag's resources and reset the values.
138: */
139: public void release() {
140: // let the super release
141: super .release();
142:
143: // reset the original value place holders
144: originalNesting = null;
145: originalNestingName = null;
146: }
147: }
|