1 9 package org.jboss.portal.core.servlet.jsp.taglib; 10 11 import java.util.Iterator ; 12 import java.util.LinkedList ; 13 14 import javax.servlet.jsp.JspException ; 15 import javax.servlet.jsp.tagext.TagSupport ; 16 17 import org.jboss.portal.common.context.Context; 18 import org.jboss.portal.common.context.NamedContext; 19 import org.jboss.portal.core.servlet.jsp.PortalJsp; 20 21 26 public class IfTag 27 extends TagSupport 28 { 29 32 private String ctx; 33 34 private Iterator children; 35 36 private LinkedList contextStack; 37 38 private boolean include = false; 39 40 43 public void setCtx(String ctx) 44 { 45 this.ctx = ctx; 46 } 47 48 49 public int doStartTag() throws JspException 50 { 51 contextStack = (LinkedList )PortalJsp.contextStack.get(); 52 53 if (contextStack.isEmpty()) { 55 include = false; 56 PortalJsp.log.debug("No context has been found"); 57 return SKIP_BODY; 58 } 59 60 Context currentContext = ((NamedContext)contextStack.getLast()).getContext(); 61 children = currentContext.childIterator(ctx); 62 63 if (children.hasNext()) 64 { 65 include = true; 66 contextStack.addLast(new NamedContext(ctx, (Context)children.next())); 67 return EVAL_PAGE; 68 } else { 69 include = false; 70 return SKIP_BODY; 71 } 72 } 73 74 public int doEndTag() { 75 if (include) { 76 contextStack.removeLast(); 77 } 78 return SKIP_BODY; 79 } 80 81 82 121 } 122 | Popular Tags |