KickJava   Java API By Example, From Geeks To Geeks.

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


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  *
21  * As NodeTag, but the node (which should be a user) will be connected to
22  * the indicated channel at the start of the body.
23  *
24  * @author Pierre van Rooden
25  * @version $Id: ConnectionTag.java,v 1.4 2003/06/18 20:03:56 michiel Exp $
26  */

27  
28 public class ConnectionTag extends NodeTag {
29
30     public final static String JavaDoc JOIN = "JOIN";
31     public final static String JavaDoc LEAVE = "LEAVE";
32     public final static String JavaDoc STILLACTIVE = "STILLACTIVE";
33
34     String JavaDoc channel=null;
35     String JavaDoc action=STILLACTIVE;
36
37     public void setChannel(String JavaDoc c) throws JspTagException JavaDoc {
38         channel=getAttributeValue(c);
39     }
40
41     public void setAction(String JavaDoc a) throws JspTagException JavaDoc {
42         action=getAttributeValue(a).toUpperCase();
43         if (!action.equals(JOIN) &&
44             !action.equals(LEAVE) &&
45             !action.equals(STILLACTIVE)) {
46             throw new JspTagException JavaDoc("Action need be one of JOIN, LEAVE or STILLACTIVE.");
47         }
48     }
49
50     public void setUser(String JavaDoc u) throws JspTagException JavaDoc {
51         setNumber(u);
52     }
53
54     public int doStartTag() throws JspTagException JavaDoc {
55         super.doStartTag() ;
56         Module community=getCloudContext().getModule("communityprc");
57         Node node=getNodeVar();
58         community.getInfo("CHANNEL-"+channel+"-"+action+"-"+node.getNumber(),pageContext.getRequest(),pageContext.getResponse());
59         return EVAL_BODY_BUFFERED;
60     }
61 }
62
Popular Tags