1 10 package org.mmbase.applications.community.taglib; 11 12 import javax.servlet.jsp.JspTagException ; 13 14 import org.mmbase.bridge.Node; 15 import org.mmbase.bridge.Module; 16 17 import org.mmbase.bridge.jsp.taglib.NodeTag; 18 19 27 28 public class TestChannelTag extends NodeTag { 29 30 public final static String OPEN = "OPEN"; 31 public final static String READONLY = "READONLY"; 32 public final static String CLOSED = "CLOSED"; 33 34 String condition=OPEN; 35 boolean reverse=false; 36 37 public void setChannel(String c) throws JspTagException { 38 setNumber(c); 39 } 40 41 public void setCondition(String c) throws JspTagException { 42 condition=getAttributeValue(c).toUpperCase(); 43 if (!condition.equals(OPEN) && 44 !condition.equals(CLOSED) && 45 !condition.equals(READONLY)) { 46 throw new JspTagException ("Condition need be one of OPEN, CLOSED or READONLY."); 47 } 48 } 49 50 public void setReverse(boolean r) { 51 reverse=r; 52 } 53 54 57 public int doStartTag() throws JspTagException { 58 if (super.doStartTag()==EVAL_BODY_BUFFERED) { 59 Node node=getNodeVar(); 60 Module community=getCloudContext().getModule("communityprc"); 61 String state=community.getInfo("CHANNEL-"+node.getNumber()+"-ISOPEN",pageContext.getRequest(),pageContext.getResponse()); 62 boolean result=state.equalsIgnoreCase(condition); 63 if (result!=reverse) 64 return EVAL_BODY_BUFFERED; 65 } 66 return SKIP_BODY; 67 } 68 69 } 70 | Popular Tags |