KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > pageflow > PresentTag


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.pageflow;
11
12 import org.mmbase.bridge.jsp.taglib.util.Attribute;
13 import org.mmbase.bridge.jsp.taglib.*;
14
15 import javax.servlet.jsp.JspTagException JavaDoc;
16
17
18 /**
19  * A very simple tag to check if certain id is present in the parent context.
20  *
21  * @author Michiel Meeuwissen
22  * @version $Id: PresentTag.java,v 1.20 2004/07/19 15:28:31 michiel Exp $
23  */

24
25 public class PresentTag extends ContextReferrerTag implements Condition {
26
27     protected Attribute inverse = Attribute.NULL;
28
29     public void setInverse(String JavaDoc b) throws JspTagException JavaDoc {
30         inverse = getAttribute(b);
31     }
32     protected boolean getInverse() throws JspTagException JavaDoc {
33         return inverse.getBoolean(this, false);
34     }
35
36     public int doStartTag() throws JspTagException JavaDoc {
37         if ((getContextProvider().getContextContainer().isPresent(getReferid())) != getInverse()) {
38             return EVAL_BODY;
39         } else {
40             return SKIP_BODY;
41         }
42     }
43     
44     public int doAfterBody() throws JspTagException JavaDoc {
45         if (EVAL_BODY == EVAL_BODY_BUFFERED) { // not needed if EVAL_BODY_INCLUDE
46
if (bodyContent != null) {
47                 try{
48                     if(bodyContent != null) {
49                         bodyContent.writeOut(bodyContent.getEnclosingWriter());
50                     }
51                 } catch(java.io.IOException JavaDoc e){
52                     throw new TaglibException(e);
53                 }
54             }
55         }
56         return SKIP_BODY;
57     }
58 }
59
Popular Tags