1 18 package org.apache.struts.taglib.nested.html; 19 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.jsp.JspException ; 22 23 import org.apache.struts.taglib.html.LinkTag; 24 import org.apache.struts.taglib.nested.NestedNameSupport; 25 import org.apache.struts.taglib.nested.NestedPropertyHelper; 26 27 32 public class NestedLinkTag extends LinkTag implements NestedNameSupport { 33 34 40 public int doStartTag() throws JspException { 41 origName = super.getName(); 42 origProperty = super.getProperty(); 43 origParamProperty = super.getParamProperty(); 44 45 46 boolean doProperty = (origProperty != null && origProperty.length() > 0); 47 boolean doParam = (origParamProperty != null && origParamProperty.length() > 0); 48 49 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 51 52 boolean hasName = (getName() != null && getName().trim().length() > 0); 53 String currentName; 54 if (hasName) { 55 currentName = getName(); 56 } else { 57 currentName = NestedPropertyHelper.getCurrentName(request, this); 58 } 59 super.setName(currentName); 61 62 if (doProperty && !hasName) { 64 super.setProperty(NestedPropertyHelper.getAdjustedProperty(request, origProperty)); 65 } 66 if (doParam) { 68 super.setName(null); 69 super.setParamName(currentName); 70 super.setParamProperty(NestedPropertyHelper.getAdjustedProperty(request, origParamProperty)); 71 } 72 73 74 return super.doStartTag(); 75 } 76 77 83 public int doEndTag() throws JspException { 84 int i = super.doEndTag(); 86 87 setName(origName); 89 setProperty(origProperty); 90 setParamProperty(origParamProperty); 91 92 return i; 94 } 95 96 99 public void release() { 100 super.release(); 101 origName = null; 103 origProperty = null; 104 origParamProperty = null; 105 } 106 107 108 109 private String origName = null; 110 private String origProperty = null; 111 private String origParamProperty = null; 112 } 113 | Popular Tags |