1 16 17 package org.apache.taglibs.xtags.xpath; 18 19 20 21 import java.util.List ; 22 23 import javax.servlet.jsp.JspException ; 24 25 import org.dom4j.Node; 26 import org.dom4j.NodeFilter; 27 import org.dom4j.DocumentHelper; 28 29 34 public class WhenTag extends AbstractTag { 35 36 37 private NodeFilter nodeFilter; 38 39 public WhenTag() { 41 } 42 43 public int doStartTag() throws JspException { 46 ChooseTag tag = (ChooseTag) findAncestorWithClass( this, ChooseTag.class ); 47 if ( tag != null && ! tag.isEvaluated() ) { 48 if ( evaluate() ) { 49 tag.setEvaluated(true); 50 return EVAL_BODY_INCLUDE; 51 } 52 } 53 return SKIP_BODY; 54 } 55 56 public boolean evaluate() throws JspException { 59 if ( nodeFilter != null ) { 60 return matches( nodeFilter ); 61 } 62 return false; 63 } 64 65 public void setTest( String test ) { 66 nodeFilter = createXPathFilter( test ); 67 } 68 69 public void setFilter( NodeFilter nodeFilter ) { 70 this.nodeFilter = nodeFilter; 71 } 72 } 73 | Popular Tags |