KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > functions > HasFunctionTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

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 JavaDoc;
17 import org.mmbase.util.logging.*;
18
19 /**
20  *
21  * @author Michiel Meeuwissen
22  * @version $Id: HasFunctionTag.java,v 1.3 2006/05/08 21:51:38 michiel Exp $
23  * @since MMBase-1.8
24  */

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 JavaDoc b) throws JspTagException JavaDoc {
32         inverse = getAttribute(b);
33     }
34     protected boolean getInverse() throws JspTagException JavaDoc {
35         return inverse.getBoolean(this, false);
36     }
37
38     public int doStartTag() throws JspTagException JavaDoc {
39         boolean found;
40         try {
41             found = getFunction() != null;
42         } catch (NotFoundException nfe) {
43             found = false;
44         } catch (java.lang.reflect.UndeclaredThrowableException JavaDoc ute) {
45             // can happen on modules, which are proxies.
46
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 JavaDoc {
55         if (EVAL_BODY == EVAL_BODY_BUFFERED) { // not needed if EVAL_BODY_INCLUDE
56
try{
57                 if(bodyContent != null) {
58                     bodyContent.writeOut(bodyContent.getEnclosingWriter());
59                 }
60             } catch(java.io.IOException JavaDoc e){
61                 throw new JspTagException JavaDoc("IO Error: " + e.getMessage());
62             }
63         }
64         return SKIP_BODY;
65     }
66 }
67
Popular Tags