1 21 package net.mlw.vlh.web.tag.support; 22 23 import javax.servlet.jsp.JspException ; 24 import javax.servlet.jsp.tagext.BodyTagSupport ; 25 26 import net.mlw.vlh.web.util.JspUtils; 27 28 34 public class AttributeTag extends BodyTagSupport 35 { 36 37 private String name; 38 39 40 private String value; 41 42 45 public int doStartTag() throws JspException 46 { 47 Attributeable parent = (Attributeable) JspUtils.getParent(this, Attributeable.class); 48 if (value != null) 49 { 50 parent.setCellAttribute(name, value); 51 value = null; 52 return SKIP_BODY; 53 } 54 else 55 { 56 return EVAL_BODY_AGAIN; 57 } 58 } 59 60 63 public int doAfterBody() throws JspException 64 { 65 Attributeable parent = (Attributeable) getParent(); 66 parent.setCellAttribute(name, bodyContent.getString()); 67 bodyContent.clearBody(); 68 return SKIP_BODY; 69 } 70 71 74 public int doEndTag() throws JspException 75 { 76 int result = super.doEndTag(); 77 reset(); 78 return result; 79 } 80 81 84 public String getName() 85 { 86 return name; 87 } 88 89 95 public void setName(String name) 96 { 97 this.name = name; 98 } 99 100 103 public String getValue() 104 { 105 return value; 106 } 107 108 114 public void setValue(String value) 115 { 116 this.value = value; 117 } 118 119 private void reset() 120 { 121 this.name = null; 122 this.value = null; 123 } 124 125 133 public void release() 134 { 135 super.release(); 136 reset(); 137 } 138 } | Popular Tags |