KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > community > taglib > CommunityTag


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.applications.community.taglib;
11
12 import javax.servlet.jsp.JspTagException JavaDoc;
13
14 import org.mmbase.bridge.Node;
15 import org.mmbase.bridge.Module;
16
17 import org.mmbase.bridge.jsp.taglib.NodeTag;
18
19 /**
20  * As NodeTag, but the node (which should be a commnity) will be opened or
21  * closed at the start of the body, depending on the action given.
22  * This affects all channels of this community.
23  *
24  * @author Pierre van Rooden
25  * @version $Id: CommunityTag.java,v 1.4 2003/06/18 20:03:56 michiel Exp $
26  */

27  
28 public class CommunityTag extends NodeTag {
29
30     public final static String JavaDoc OPEN = "OPEN";
31     public final static String JavaDoc CLOSE = "CLOSE";
32
33     String JavaDoc action=OPEN;
34
35     public void setCommunity(String JavaDoc c) throws JspTagException JavaDoc {
36         setNumber(c);
37     }
38
39     public void setAction(String JavaDoc c) throws JspTagException JavaDoc {
40         action=getAttributeValue(c).toUpperCase();
41         if (!action.equals(OPEN) &&
42             !action.equals(CLOSE)) {
43             throw new JspTagException JavaDoc("Action need be one of OPEN, CLOSE or READONLY.");
44         }
45     }
46
47     public int doStartTag() throws JspTagException JavaDoc {
48         super.doStartTag() ;
49         Module community=getCloudContext().getModule("communityprc");
50         Node node=getNodeVar();
51         community.getInfo("COMMUNITY-"+node.getNumber()+"-"+action,pageContext.getRequest(),pageContext.getResponse());
52         return EVAL_BODY_BUFFERED;
53     }
54 }
55
Popular Tags