1 10 package org.mmbase.bridge.jsp.taglib.security; 11 12 import org.mmbase.bridge.*; 13 import org.mmbase.bridge.jsp.taglib.util.Attribute; 14 import org.mmbase.bridge.jsp.taglib.Condition; 15 import org.mmbase.bridge.jsp.taglib.NodeReferrerTag; 16 17 import javax.servlet.jsp.JspTagException ; 18 19 20 26 27 public class MayWriteTag extends NodeReferrerTag implements Condition { 28 29 protected Attribute inverse = Attribute.NULL; 30 protected Attribute number = Attribute.NULL; 31 32 public void setInverse(String b) throws JspTagException { 33 inverse = getAttribute(b); 34 } 35 public void setNumber(String n) throws JspTagException { 36 number = getAttribute(n); 37 } 38 protected boolean getInverse() throws JspTagException { 39 return inverse.getBoolean(this, false); 40 } 41 42 protected Node getNodeToCheck() throws JspTagException { 43 Node node; 44 String n = number.getString(this); 45 if ("".equals(n)) { 46 node = getNode(); 47 } else { 48 node = getCloudVar().getNode(n); 49 } 50 return node; 51 } 52 53 public int doStartTag() throws JspTagException { 54 if ((getNodeToCheck().mayWrite()) != getInverse()) { 55 return EVAL_BODY; 56 } else { 57 return SKIP_BODY; 58 } 59 } 60 public int doAfterBody() throws JspTagException { 61 if (EVAL_BODY == EVAL_BODY_BUFFERED) { try{ 63 if(bodyContent != null) { 64 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 65 } 66 } catch(java.io.IOException e){ 67 throw new JspTagException ("IO Error: " + e.getMessage()); 68 } 69 } 70 return SKIP_BODY; 71 } 72 } 73 | Popular Tags |