1 28 29 package com.caucho.jstl.rt; 30 31 import com.caucho.jstl.NameValueTag; 32 import com.caucho.util.L10N; 33 34 import javax.servlet.jsp.JspException ; 35 import javax.servlet.jsp.tagext.BodyTagSupport ; 36 37 40 public class XmlParamTag extends BodyTagSupport { 41 private static L10N L = new L10N(XmlParamTag.class); 42 43 private String _name; 44 private String _value; 45 46 51 public void setName(String name) 52 { 53 _name = name; 54 } 55 56 61 public void setValue(String value) 62 { 63 _value = value; 64 } 65 66 69 public int doStartTag() 70 throws JspException 71 { 72 if (_value == null) 73 return EVAL_BODY_BUFFERED; 74 75 Object parent = getParent(); 76 if (! (parent instanceof NameValueTag)) 77 throw new JspException (L.l("x:param requires x:transform parent.")); 78 79 NameValueTag tag = (NameValueTag) parent; 80 81 tag.addParam(_name, _value); 82 83 return SKIP_BODY; 84 } 85 86 89 public int doEndTag() 90 throws JspException 91 { 92 if (_value != null) 93 return EVAL_PAGE; 94 95 String value; 96 97 if (bodyContent != null) 98 value = bodyContent.getString().trim(); 99 else 100 value = ""; 101 102 Object parent = getParent(); 103 if (! (parent instanceof NameValueTag)) 104 throw new JspException (L.l("x:param requires x:transform parent.")); 105 106 NameValueTag tag = (NameValueTag) parent; 107 108 tag.addParam(_name, value); 109 110 return EVAL_PAGE; 111 } 112 } 113 | Popular Tags |