1 package com.tonbeller.wcf.param; 2 3 import javax.servlet.jsp.JspException ; 4 import javax.servlet.jsp.tagext.TagSupport ; 5 6 import org.apache.log4j.Logger; 7 8 import com.tonbeller.wcf.expr.ExprUtils; 9 10 14 public class SetParamTagBase extends TagSupport { 15 String displayName; 16 String displayValue; 17 String paramName; 18 String sqlValue; 19 String mdxValue; 20 String textValue; 21 22 private static final Logger logger = Logger.getLogger(SetParamTagBase.class); 23 24 SessionParam oldParam; 26 SessionParam newParam; 27 28 public int doStartTag() throws JspException { 29 SessionParamPool pool = SessionParamPool.instance(pageContext); 30 oldParam = pool.getParam(paramName); 32 33 try { 35 if (oldParam == null) { 36 newParam = new SessionParam(); 37 newParam.setName(paramName); 38 } 39 else 40 newParam = (SessionParam) oldParam.clone(); 41 } catch (CloneNotSupportedException e) { 42 logger.error(null, e); 43 throw new JspException (e); 44 } 45 46 initialize(newParam); 48 pool.setParam(newParam); 49 return EVAL_BODY_INCLUDE; 50 } 51 52 protected void initialize(SessionParam p) { 53 if (displayName != null) 54 p.setDisplayName(evalStr(displayName)); 55 if (displayValue != null) 56 p.setDisplayValue(evalStr(displayValue)); 57 if (paramName != null) 58 p.setName(evalStr(paramName)); 59 if (sqlValue != null) 60 p.setSqlValue(evalObj(sqlValue)); 61 if (mdxValue != null) 62 p.setMdxValue(evalStr(mdxValue)); 63 if (textValue != null) 64 p.setMdxValue(evalStr(mdxValue)); 65 } 66 67 protected Object evalObj(String s) { 68 if (ExprUtils.isExpression(s)) 69 return ExprUtils.getModelReference(pageContext, s); 70 return s; 71 } 72 73 protected String evalStr(String s) { 74 if (ExprUtils.isExpression(s)) 75 return String.valueOf(ExprUtils.getModelReference(pageContext, s)); 76 return s; 77 } 78 79 public void setDisplayName(String displayName) { 80 this.displayName = displayName; 81 } 82 83 public void setDisplayValue(String displayValue) { 84 this.displayValue = displayValue; 85 } 86 87 public void setMdxValue(String mdxValue) { 88 this.mdxValue = mdxValue; 89 } 90 91 public void setParamName(String paramName) { 92 this.paramName = paramName; 93 } 94 95 public void setSqlValue(String sqlExpr) { 96 this.sqlValue = sqlExpr; 97 } 98 99 public void setTextValue(String textValue) { 100 this.textValue = textValue; 101 } 102 103 } 104 | Popular Tags |