1 23 24 27 package org.dbforms.taglib; 28 29 import org.dbforms.util.Util; 30 31 import java.util.Vector ; 32 33 import javax.servlet.jsp.JspException ; 34 import javax.servlet.jsp.PageContext ; 35 import javax.servlet.jsp.tagext.BodyTagSupport ; 36 37 38 39 49 public class HasErrorTag extends BodyTagSupport 50 implements javax.servlet.jsp.tagext.TryCatchFinally { 51 private String name = "errors"; 53 private String value = "true"; 54 55 60 public void setName(String name) { 61 this.name = name; 62 } 63 64 65 70 public String getName() { 71 return (this.name); 72 } 73 74 75 80 public void setValue(String string) { 81 value = string; 82 } 83 84 85 90 public String getValue() { 91 return value; 92 } 93 94 95 102 public void doCatch(Throwable t) throws Throwable { 103 throw t; 104 } 105 106 107 110 public void doFinally() { 111 name = "errors"; 112 value = "true"; 113 } 114 115 116 118 125 public int doStartTag() throws JspException { 126 Vector originalErrors = (Vector ) pageContext.getAttribute(getName(), 127 PageContext.REQUEST_SCOPE); 128 boolean haveError = false; 129 130 haveError = (((originalErrors != null) && (originalErrors.size() > 0))); 131 132 return (Util.getTrue(value) == haveError) ? EVAL_BODY_INCLUDE 133 : SKIP_BODY; 134 } 135 } 136 | Popular Tags |