1 18 package org.apache.struts.taglib.nested; 19 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.jsp.JspException ; 22 import javax.servlet.jsp.tagext.BodyTagSupport ; 23 24 import org.apache.struts.taglib.TagUtils; 25 26 44 public class NestedRootTag extends BodyTagSupport implements NestedNameSupport { 45 46 49 public String getProperty() { 50 return ""; 51 } 52 55 public void setProperty(String property) {} 56 57 60 public String getName() { 61 return this.name; 62 } 63 66 public void setName(String name) { 67 this.name = name; 68 } 69 70 76 public int doStartTag() throws JspException { 77 78 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 79 80 originalName = name; 82 originalNesting = NestedPropertyHelper.getCurrentProperty(request); 83 originalNestingName = NestedPropertyHelper.getCurrentName(request, this); 84 85 if (name != null) { 87 NestedPropertyHelper.setProperty(request, ""); 88 NestedPropertyHelper.setName(request, this.name); 89 } 90 91 return (EVAL_BODY_TAG); 93 } 94 95 100 public int doAfterBody() throws JspException { 101 102 if (bodyContent != null) { 103 TagUtils.getInstance().writePrevious(pageContext, bodyContent.getString()); 104 bodyContent.clearBody(); 105 } 106 107 return (SKIP_BODY); 108 } 109 110 115 public int doEndTag() throws JspException { 116 117 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 118 119 if (originalNesting == null) { 120 NestedPropertyHelper.deleteReference(request); 121 } else { 122 NestedPropertyHelper.setName(request, originalNestingName); 123 NestedPropertyHelper.setProperty(request, originalNesting); 124 } 125 this.name = originalName; 126 127 return (EVAL_PAGE); 128 } 129 130 131 134 public void release() { 135 super.release(); 136 this.name = null; 137 this.originalName = null; 138 this.originalNesting = null; 139 this.originalNestingName = null; 140 } 141 142 143 private String name = null; 144 private String originalName = ""; 145 private String originalNesting = ""; 146 private String originalNestingName = ""; 147 } 148 | Popular Tags |