1 10 package org.mmbase.bridge.jsp.taglib; 11 import javax.servlet.jsp.*; 12 13 import org.mmbase.bridge.*; 14 import org.mmbase.bridge.jsp.taglib.util.Attribute; 15 import org.mmbase.util.logging.*; 16 17 25 26 public class CountRelationsTag extends NodeReferrerTag implements Writer { 27 28 private static final Logger log = Logging.getLoggerInstance(CountRelationsTag.class); 29 private Attribute type = Attribute.NULL; 30 private Attribute searchDir = Attribute.NULL; 31 private Attribute role = Attribute.NULL; 32 33 37 public void setType(String type) throws JspTagException { 38 this.type = getAttribute(type); 39 } 40 41 public void setSearchdir(String s) throws JspTagException { 42 searchDir = getAttribute(s); 43 } 44 45 public void setRole(String r) throws JspTagException { 46 role = getAttribute(r); 47 } 48 49 public int doStartTag() throws JspTagException { 50 51 if (getReferid() != null) { 52 helper.setValue(getContextProvider().getContextContainer().getObject(getReferid())); 53 } else { 54 log.debug("Search the node."); 55 Node node = getNode(); 56 Cloud cloud = node.getCloud(); 57 NodeManager other = 58 type == Attribute.NULL ? 59 cloud.getNodeManager("object") : 60 cloud.getNodeManager(type.getString(this)); 61 String direction = (String ) searchDir.getValue(this); 62 if (direction == null) direction = "BOTH"; 63 helper.setValue(new Integer (node.countRelatedNodes(other, (String ) role.getValue(this), direction))); 64 } 65 if (getId() != null) { 66 getContextProvider().getContextContainer().register(getId(), helper.getValue()); 67 } 68 return EVAL_BODY_BUFFERED; 69 } 70 71 public int doAfterBody() throws JspException { 72 return helper.doAfterBody(); 73 } 74 75 public int doEndTag() throws JspTagException { 76 helper.doEndTag(); 77 return super.doEndTag(); 78 79 } 80 } 81 | Popular Tags |