1 64 65 package com.jcorporate.expresso.ext.taglib; 66 67 72 73 import com.jcorporate.expresso.core.ExpressoConstants; 74 import com.jcorporate.expresso.core.controller.ControllerResponse; 75 import org.apache.log4j.Logger; 76 77 import javax.servlet.jsp.JspException ; 78 import javax.servlet.jsp.PageContext ; 79 import javax.servlet.jsp.tagext.Tag ; 80 import javax.servlet.jsp.tagext.TagSupport ; 81 82 83 86 public abstract class ExpressoTagSupport 87 extends TagSupport { 88 protected ControllerResponse ctlrResp = null; 89 protected java.lang.String response = null; 90 private static Logger log = Logger.getLogger(ExpressoTagSupport.class); 91 92 public ExpressoTagSupport() { 93 super(); 94 } 95 96 protected TagSupport getAncestor(String className) 97 throws JspException { 98 Class klass = null; 99 100 try { 101 klass = Class.forName(className); 102 } catch (ClassNotFoundException ex) { 103 log.error("No such class '" + className + "'", ex); 104 throw new JspException (ex.getMessage()); 105 } 106 107 return (TagSupport ) findAncestorWithClass(this, klass); 108 } 109 110 protected Tag getContainer() 111 throws JspException { 112 Tag parent = this; 113 114 while ((parent = parent.getParent()) != null) { 115 if ((parent instanceof BlockTag) || 116 (parent instanceof ElementIterator) || 117 (parent instanceof OutputTag)) { 118 return parent; 119 } 120 } 121 122 return null; 123 } 124 125 protected void getControllerResponse() { 126 if (response == null || response.length() == 0) { 127 response = ExpressoConstants.CONTROLLER_RESPONSE_KEY; 128 } 129 130 ctlrResp = (ControllerResponse) pageContext.getAttribute(response, 131 PageContext.REQUEST_SCOPE); 132 } 133 134 public java.lang.String getResponse() { 135 return response; 136 } 137 138 public void setResponse(java.lang.String newResponse) { 139 response = newResponse; 140 } 141 } 142 143 | Popular Tags |