1 21 package net.mlw.vlh.web.tag; 22 23 import java.util.HashMap ; 24 import java.util.Map ; 25 26 import javax.servlet.jsp.JspException ; 27 import javax.servlet.jsp.tagext.BodyTagSupport ; 28 29 import net.mlw.vlh.ValueList; 30 import net.mlw.vlh.web.tag.support.Attributeable; 31 import net.mlw.vlh.web.util.JspUtils; 32 33 38 public class FilterTag extends BodyTagSupport implements Attributeable 39 { 40 41 private String url; 42 43 private Map parameters; 44 45 private ValueListSpaceTag rootTag; 46 47 50 public int doStartTag() throws JspException 51 { 52 rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class); 53 54 parameters = new HashMap (rootTag.getTableInfo().getParameters()); 55 return super.doStartTag(); 56 } 57 58 61 public int doEndTag() throws JspException 62 { 63 64 ValueList valueList = rootTag.getValueList(); 65 66 StringBuffer sb = new StringBuffer (); 67 sb.append("<a HREF=\"").append(url); 68 sb.append(rootTag.getConfig().getLinkEncoder().encode(pageContext, parameters)); 69 sb.append("\">"); 70 sb.append(getBodyContent().getString()); 71 sb.append("</a>"); 72 73 JspUtils.write(pageContext, sb.toString()); 74 75 release(); 76 77 return EVAL_PAGE; 78 } 79 80 83 public void setCellAttribute(String name, String value) 84 { 85 parameters.put(name, value); 86 } 87 88 93 public void appendClassCellAttribute(String name, String value) 94 { 95 parameters.put(name, value); 96 } 97 98 101 public void setUrl(String url) 102 { 103 this.url = url; 104 } 105 106 private void reset() 107 { 108 this.rootTag = null; 109 this.parameters = null; 110 this.url = null; 111 } 112 113 121 public void release() 122 { 123 super.release(); 124 reset(); 125 } 126 } | Popular Tags |