KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.*;
13
14 import javax.servlet.jsp.JspTagException JavaDoc;
15
16 import org.mmbase.bridge.*;
17 import org.mmbase.bridge.jsp.taglib.*;
18 import org.mmbase.bridge.jsp.taglib.util.Attribute;
19
20 /**
21  * Who tag, provides functionality for listing users of a channel.
22  *
23  * @author Pierre van Rooden
24  * @version $Id: WhoTag.java,v 1.12 2005/01/30 16:46:35 nico Exp $
25  */

26  
27 public class WhoTag extends AbstractNodeListTag {
28
29     private String JavaDoc channel= null;
30
31     protected Module community = null;
32
33     public void setChannel(String JavaDoc channel) throws JspTagException JavaDoc {
34         this.channel= getAttributeValue(channel);
35     }
36
37     public int doStartTag() throws JspTagException JavaDoc {
38         //this is where we do the seach
39
// XXX: have to add some error checking too
40
community=getCloudContext().getModule("communityprc");
41         if (community==null) throw new JspTagException JavaDoc("Community module is not active");
42         if (channel==null) { // must be the surrounding node
43
Node n = getNode();
44             channel = n.getStringValue("number");
45         }
46
47         Hashtable params=new Hashtable();
48         params.put("CHANNEL",channel);
49         try {
50             Cloud cloud=getCloudVar();
51             params.put("CLOUD",cloud);
52         } catch (JspTagException JavaDoc e) {}
53
54         if (orderby != null) params.put("SORTFIELDS",orderby);
55         if (directions !=null) params.put("SORTDIRS", directions);
56         Attribute max = listHelper.getMax();
57         Attribute offset = listHelper.getOffset();
58         if (offset != Attribute.NULL) params.put("FROMCOUNT", "" + offset.getInt(this, 0));
59         if (max != Attribute.NULL) params.put("MAX", max.getString(this));
60         NodeList nodes = community.getList("WHO", params, pageContext.getRequest(), pageContext.getResponse());
61         return setReturnValues(nodes,false);
62     }
63 }
Popular Tags