KickJava   Java API By Example, From Geeks To Geeks.

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


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 channel) will be opened or
21  * closed at the start of the body, depending on the action given.
22  *
23  * @author Pierre van Rooden
24  * @version $Id: ChannelTag.java,v 1.4 2003/06/18 20:03:56 michiel Exp $
25  */

26  
27 public class ChannelTag extends NodeTag {
28
29     public final static String JavaDoc OPEN = "OPEN";
30     public final static String JavaDoc READONLY = "READONLY";
31     public final static String JavaDoc CLOSE = "CLOSE";
32
33     String JavaDoc action=OPEN;
34
35     public void setChannel(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             !action.equals(READONLY)) {
44             throw new JspTagException JavaDoc("Action need be one of OPEN, CLOSE or READONLY.");
45         }
46     }
47
48     public int doStartTag() throws JspTagException JavaDoc {
49         super.doStartTag() ;
50         Module community=getCloudContext().getModule("communityprc");
51         Node node=getNodeVar();
52         community.getInfo("CHANNEL-"+node.getNumber()+"-"+action,pageContext.getRequest(),pageContext.getResponse());
53         return EVAL_BODY_BUFFERED;
54     }
55 }
56
Popular Tags