1 10 package org.mmbase.bridge.jsp.taglib.functions; 11 12 import org.mmbase.bridge.jsp.taglib.util.Attribute; 13 import org.mmbase.bridge.jsp.taglib.Condition; 14 import org.mmbase.bridge.NotFoundException; 15 16 import javax.servlet.jsp.JspTagException ; 17 import org.mmbase.util.logging.*; 18 19 25 26 public class HasFunctionTag extends AbstractFunctionTag implements Condition { 27 private static final Logger log = Logging.getLoggerInstance(HasFunctionTag.class); 28 29 protected Attribute inverse = Attribute.NULL; 30 31 public void setInverse(String b) throws JspTagException { 32 inverse = getAttribute(b); 33 } 34 protected boolean getInverse() throws JspTagException { 35 return inverse.getBoolean(this, false); 36 } 37 38 public int doStartTag() throws JspTagException { 39 boolean found; 40 try { 41 found = getFunction() != null; 42 } catch (NotFoundException nfe) { 43 found = false; 44 } catch (java.lang.reflect.UndeclaredThrowableException ute) { 45 found = false; 47 } 48 if (found != getInverse()) { 49 return EVAL_BODY; 50 } else { 51 return SKIP_BODY; 52 } 53 } 54 public int doAfterBody() throws JspTagException { 55 if (EVAL_BODY == EVAL_BODY_BUFFERED) { try{ 57 if(bodyContent != null) { 58 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 59 } 60 } catch(java.io.IOException e){ 61 throw new JspTagException ("IO Error: " + e.getMessage()); 62 } 63 } 64 return SKIP_BODY; 65 } 66 } 67 | Popular Tags |