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 39 public class NestedPropertyTag extends BodyTagSupport implements NestedNameSupport { 40 41 public String getName() { return null; } 42 public void setName(String newNamed) {} 43 44 47 public String getProperty() { 48 return this.property; 49 } 50 51 56 public void setProperty(String newProperty) { 57 property = newProperty; 58 } 59 60 66 public int doStartTag() throws JspException { 67 originalProperty = property; 68 69 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 70 originalNest = NestedPropertyHelper.getCurrentProperty(request); 71 originalName = NestedPropertyHelper.getCurrentName(request, this); 72 73 String nested = NestedPropertyHelper.getAdjustedProperty(request, originalProperty); 74 NestedPropertyHelper.setProperty(request, nested); 75 NestedPropertyHelper.setName(request, originalName); 76 77 return (EVAL_BODY_TAG); 79 } 80 81 82 87 public int doAfterBody() throws JspException { 88 89 90 if (bodyContent != null) { 91 TagUtils.getInstance().writePrevious(pageContext, bodyContent.getString()); 92 bodyContent.clearBody(); 93 } 94 95 return (SKIP_BODY); 96 } 97 98 99 104 public int doEndTag() throws JspException { 105 106 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 107 if (originalNest == null && originalName == null) { 108 NestedPropertyHelper.deleteReference(request); 109 } else { 110 NestedPropertyHelper.setName(request, originalName); 111 NestedPropertyHelper.setProperty(request, originalNest); 112 } 113 property = originalProperty; 114 return (EVAL_PAGE); 115 } 116 117 118 121 public void release() { 122 super.release(); 123 this.property = null; 124 this.originalNest = null; 125 this.originalName = null; 126 this.originalProperty = null; 127 } 128 129 130 private String property = null; 131 private String originalNest = null; 132 private String originalName = null; 133 private String originalProperty = null; 134 } 135 | Popular Tags |