1 8 9 10 package org.apache.roller.ui.core.tags; 11 12 import org.apache.log4j.Category; 13 import org.apache.struts.util.RequestUtils; 14 15 import javax.servlet.jsp.JspException ; 16 import javax.servlet.jsp.tagext.BodyContent ; 17 import javax.servlet.jsp.tagext.BodyTagSupport ; 18 19 30 31 public class LinkParamTag extends BodyTagSupport { 32 static Category cat = Category.getInstance(LinkParamTag.class); 34 35 39 private String id = null; 40 41 44 private String value = null; 45 46 49 private String name = null; 50 51 54 private String property = null; 55 56 59 private String scope = null; 60 61 62 64 69 public void setId(String id) { 70 this.id = id; 71 } 72 73 78 public String getId() { 79 return id; 80 } 81 82 87 public void setValue(String value) { 88 this.value = value; 89 } 90 91 96 public String getValue() { 97 return value; 98 } 99 100 104 public void setName ( String sourceBean) { 105 this.name = sourceBean; 106 } 107 108 112 public String getName () { 113 return this.name; 114 } 115 116 120 public void setProperty(String sourceProperty) { 121 this.property = sourceProperty; 122 } 123 124 128 public String getProperty() { 129 return property; 130 } 131 132 136 public void setScope(String sourceScope) { 137 this.scope = sourceScope; 138 } 139 140 144 public String getScope() { 145 return this.scope; 146 } 147 148 149 153 public int doEndTag() throws JspException { 154 LinkTag myparent = (LinkTag)javax.servlet.jsp.tagext.TagSupport.findAncestorWithClass(this, LinkTag.class); 156 157 if (myparent == null) 158 throw new JspException ("linkparam tag not nested within link tag"); 159 else { 160 BodyContent bodyContent = getBodyContent(); 161 if (bodyContent != null && !bodyContent.getString().equals("")) { 162 setValue(bodyContent.getString()); 163 } 164 else if (getValue() == null) setValue("null"); 165 myparent.addRequestParameter(getId(), getValue()); 167 } 168 return SKIP_BODY; 169 } 170 171 174 public int doStartTag() throws javax.servlet.jsp.JspException { 175 176 if (name != null) { 178 Object beanValue = 179 RequestUtils.lookup(pageContext, name, property, scope); 180 if (cat.isDebugEnabled()) cat.debug("Value is : '" + beanValue + "'"); 181 if (beanValue == null) 182 return (EVAL_BODY_TAG); 183 184 setValue(beanValue.toString()); 186 } 187 188 return (EVAL_BODY_TAG); 190 191 } 192 } 193 | Popular Tags |