KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > HasRelationsTag


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;
11 import javax.servlet.jsp.*;
12
13 import org.mmbase.bridge.jsp.taglib.util.Attribute;
14
15
16 /**
17  * Whether current node has relations.
18  *
19  * @author Michiel Meeuwissen
20  * @version $Id: HasRelationsTag.java,v 1.2 2005/03/14 19:02:35 michiel Exp $
21  * @since MMBase-1.7
22  */

23
24 public class HasRelationsTag extends NodeReferrerTag implements Condition {
25
26     protected Attribute inverse = Attribute.NULL;
27
28     public void setInverse(String JavaDoc b) throws JspTagException {
29         inverse = getAttribute(b);
30     }
31     protected final boolean getInverse() throws JspTagException {
32         return inverse.getBoolean(this, false);
33     }
34
35     public int doStartTag() throws JspTagException {
36         if ((getNode().hasRelations()) != getInverse()) {
37             return EVAL_BODY_BUFFERED;
38         } else {
39             return SKIP_BODY;
40         }
41     }
42     public int doAfterBody() throws JspTagException {
43         try{
44             if(bodyContent != null) {
45                 bodyContent.writeOut(bodyContent.getEnclosingWriter());
46             }
47             return SKIP_BODY;
48         } catch(java.io.IOException JavaDoc e){
49             throw new JspTagException("IO Error: " + e.getMessage());
50         }
51     }
52
53
54 }
55
Popular Tags