1 2 17 package org.apache.taglibs.dbtags.preparedstatement; 18 19 import java.sql.PreparedStatement ; 20 21 import javax.servlet.jsp.JspTagException ; 22 import javax.servlet.jsp.tagext.BodyTagSupport ; 23 24 30 public class BaseSetterBodyTag extends BodyTagSupport { 31 32 protected int _position = 1; 33 protected String _attributeName = null; 34 35 40 public void setPosition(int position) { 41 _position = position; 42 } 43 44 51 public void setName(String attributeName) { 52 _attributeName = attributeName; 53 } 54 55 63 protected Object getAttribute(String name) 64 throws JspTagException { 65 Object object = pageContext.getAttribute(name); 66 67 if (object == null) { 68 throw new JspTagException ("attribute " + name + " does not exist"); 69 } 70 71 return object; 72 } 73 74 81 protected PreparedStatement getPreparedStatement() 82 throws JspTagException { 83 try { 84 PreparedStatementImplTag stmtTag = 85 (PreparedStatementImplTag) findAncestorWithClass(this, Class.forName("org.apache.taglibs.dbtags.preparedstatement.PreparedStatementImplTag")); 86 return stmtTag.getPreparedStatement(); 87 } catch (ClassNotFoundException e) { 88 throw new JspTagException (e.toString()); 89 } 90 } 91 92 public void release() { 93 _position = 1; 94 _attributeName = null; 95 } 96 } 97 | Popular Tags |