1 16 package org.apache.taglibs.standard.tag.common.sql; 17 18 import javax.servlet.jsp.JspException ; 19 import javax.servlet.jsp.JspTagException ; 20 import javax.servlet.jsp.jstl.sql.SQLExecutionTag; 21 import javax.servlet.jsp.tagext.BodyTagSupport ; 22 23 import org.apache.taglibs.standard.resources.Resources; 24 25 26 32 33 public abstract class ParamTagSupport extends BodyTagSupport { 34 protected Object value; 35 36 39 public int doEndTag() throws JspException { 40 SQLExecutionTag parent = (SQLExecutionTag) 41 findAncestorWithClass(this, SQLExecutionTag.class); 42 if (parent == null) { 43 throw new JspTagException ( 44 Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); 45 } 46 47 Object paramValue = null; 48 if (value != null) { 49 paramValue = value; 50 } 51 else if (bodyContent != null) { 52 paramValue = bodyContent.getString().trim(); 53 if (((String ) paramValue).trim().length() == 0) { 54 paramValue = null; 55 } 56 } 57 58 parent.addSQLParameter(paramValue); 59 return EVAL_PAGE; 60 } 61 } 62 | Popular Tags |