1 18 package org.apache.beehive.netui.tags.template; 19 20 import org.apache.beehive.netui.tags.AbstractClassicTag; 21 22 import javax.servlet.ServletRequest ; 23 import javax.servlet.jsp.JspException ; 24 import java.util.HashMap ; 25 26 100 public class SetAttribute extends AbstractClassicTag 101 implements TemplateConstants 102 { 103 106 private String _name; 107 108 111 private String _value; 112 113 117 public String getTagName() { 118 return "SetAttribute"; 119 } 120 121 136 public void setName(String name) { 137 _name = name; 138 } 139 140 156 public void setValue(String value) 157 throws JspException { 158 _value = value; 159 } 160 161 170 public int doStartTag() 171 throws JspException { 172 ServletRequest req = pageContext.getRequest(); 173 HashMap atts = (HashMap ) req.getAttribute(TEMPLATE_ATTRIBUTES); 174 if (atts == null) { 175 atts = new HashMap (); 176 req.setAttribute(TEMPLATE_ATTRIBUTES,atts); 177 } 178 if (hasErrors()) { 179 String s = getErrorsReport(); 180 atts.put(_name,s); 181 localRelease(); 182 return EVAL_PAGE; 183 } 184 185 atts.put(_name,_value); 186 localRelease(); 187 return EVAL_PAGE; 188 } 189 190 193 protected void localRelease() { 194 super.localRelease(); 195 _name = null; 196 _value = null; 197 } 198 } 199 | Popular Tags |