1 64 65 package com.jcorporate.expresso.ext.taglib; 66 67 import com.jcorporate.expresso.core.controller.ErrorCollection; 68 69 import javax.servlet.jsp.JspTagException ; 70 import javax.servlet.jsp.PageContext ; 71 72 73 76 public class IfErrorExists 77 extends ExpressoTagSupport { 78 private ErrorCollection errorCollection = null; 79 private java.lang.String name = null; 80 private java.lang.String nameToUse = null; 81 82 public IfErrorExists() { 83 super(); 84 } 85 86 public int doEndTag() 87 throws javax.servlet.jsp.JspTagException { 88 return EVAL_PAGE; 89 } 90 91 public int doStartTag() 92 throws javax.servlet.jsp.JspTagException { 93 nameToUse = name; 94 95 try { 96 if (nameToUse == null || "".equals(nameToUse)) { 97 nameToUse = ErrorCollection.ERRORCOLLECTIONKEY; 98 } 99 100 errorCollection = (ErrorCollection) pageContext.getAttribute(nameToUse, PageContext.REQUEST_SCOPE); 101 102 if (errorCollection == null) { 103 errorCollection = (ErrorCollection) pageContext.getAttribute(nameToUse, PageContext.SESSION_SCOPE); 104 } 105 106 if (errorCollection != null) { 107 if (errorCollection.getErrorCount() > 0) { 108 return EVAL_BODY_INCLUDE; 109 } 110 } 111 } catch (Exception e) { 112 throw new JspTagException ("IfErrorExists Tag Error: " + 113 e.getMessage()); 114 } 115 116 return SKIP_BODY; 117 } 118 119 public java.lang.String getName() { 120 return nameToUse; 121 } 122 123 public void setName(java.lang.String newName) { 124 name = newName; 125 } 126 } 127 128 | Popular Tags |