1 28 29 package com.caucho.jstl.el; 30 31 import com.caucho.el.Expr; 32 import com.caucho.jsp.PageContextImpl; 33 import com.caucho.jstl.ParamContainerTag; 34 import com.caucho.util.L10N; 35 36 import javax.servlet.jsp.JspException ; 37 import javax.servlet.jsp.tagext.BodyTagSupport ; 38 39 42 public class FmtParamTag extends BodyTagSupport { 43 private static L10N L = new L10N(FmtParamTag.class); 44 45 private Expr _valueExpr; 46 47 52 public void setValue(Expr value) 53 { 54 _valueExpr = value; 55 } 56 57 60 public int doEndTag() 61 throws JspException 62 { 63 try { 64 Object value = null; 65 66 PageContextImpl pageContext = (PageContextImpl) this.pageContext; 67 68 if (_valueExpr != null) 69 value = _valueExpr.evalObject(pageContext.getELContext()); 70 else 71 value = bodyContent.getString().trim(); 72 73 Object parent = getParent(); 74 if (! (parent instanceof ParamContainerTag)) 75 throw new JspException (L.l("fmt:param requires fmt:message parent.")); 76 77 ParamContainerTag message = (ParamContainerTag) parent; 78 79 message.addParam(value); 80 81 return EVAL_PAGE; 82 } catch (Exception e) { 83 throw new JspException (e); 84 } 85 } 86 } 87 | Popular Tags |