1 23 24 package org.dbforms.taglib; 25 26 import org.dbforms.util.KeyValuePair; 27 28 import java.sql.Connection ; 29 30 import java.util.Collection ; 31 import java.util.Vector ; 32 33 import javax.servlet.jsp.JspException ; 34 import javax.servlet.jsp.PageContext ; 35 36 37 38 44 public class StaticData extends TagSupportWithScriptHandler 45 implements javax.servlet.jsp.tagext.TryCatchFinally , StaticDataAddInterface { 46 private String name; 47 private Vector data; 48 49 58 public void setName(String name) { 59 this.name = name; 60 } 61 62 63 68 public String getName() { 69 return name; 70 } 71 72 73 78 public void addElement(KeyValuePair pair) { 79 data.add(pair); 80 } 81 82 83 90 public int doAfterBody() throws JspException { 91 pageContext.setAttribute(name, data, PageContext.PAGE_SCOPE); 93 94 return SKIP_BODY; } 96 97 98 105 public void doCatch(Throwable t) throws Throwable { 106 throw t; 107 } 108 109 110 117 public int doEndTag() throws JspException { 118 ((DataContainer) getParent()).setEmbeddedData(data); 120 return EVAL_PAGE; 121 } 122 123 124 127 public void doFinally() { 128 name = null; 129 data = null; 130 } 131 132 133 140 public int doStartTag() throws JspException { 141 data = (Vector ) pageContext.getAttribute(name, PageContext.PAGE_SCOPE); 143 144 if (data == null) { 147 data = new Vector (); 148 149 return EVAL_BODY_BUFFERED; 150 } else { 151 return SKIP_BODY; 152 } 153 } 154 155 156 163 protected Collection fetchData(Connection con) { 164 return data; 165 } 166 } 167 | Popular Tags |