1 16 package com.blandware.atleap.webapp.taglib.core; 17 18 import org.apache.commons.logging.Log; 19 import org.apache.commons.logging.LogFactory; 20 import org.apache.struts.taglib.TagUtils; 21 22 import javax.servlet.jsp.JspException ; 23 import javax.servlet.jsp.JspTagException ; 24 import javax.servlet.jsp.PageContext ; 25 import javax.servlet.jsp.tagext.SimpleTagSupport ; 26 import java.util.Collection ; 27 import java.util.HashMap ; 28 import java.util.Map ; 29 30 56 public class ParamTag extends SimpleTagSupport { 57 58 protected transient final Log log = LogFactory.getLog(ParamTag.class); 59 60 63 protected String name; 64 65 68 protected Object value; 69 70 73 protected Map parameters = new HashMap (); 74 75 84 public String getName() { 85 return name; 86 } 87 88 93 public void setName(String name) { 94 this.name = name; 95 } 96 97 106 public Object getValue() { 107 return value; 108 } 109 110 115 public void setValue(Object value) { 116 this.value = value; 117 } 118 119 124 public void doTag() throws JspException { 125 126 PageContext pageContext = (PageContext ) getJspContext(); 127 ParamParent parent = (ParamParent) findAncestorWithClass(this, ParamParent.class); 128 if ( parent == null ) { 129 JspTagException e = new JspTagException ("This tag is only valid when nested within tag which implements 'com.blandware.atleap.webapp.taglib.core.ParamParent' interface"); 130 TagUtils.getInstance().saveException(pageContext, e); 131 } 132 133 if ( !(value instanceof String ) && !(value instanceof String []) && !(value instanceof Collection ) ) { 135 value = String.valueOf(value); 136 } 137 138 parent.addParameter(name, value); 139 140 } 141 142 } 143 | Popular Tags |