1 package org.jahia.deprecated.taglibs.util; 2 3 import java.io.IOException ; 4 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.jsp.JspException ; 7 import javax.servlet.jsp.tagext.BodyTagSupport ; 8 9 import org.jahia.data.JahiaData; 10 import org.jahia.utils.JahiaConsole; 11 12 13 19 public class IfPageIdIsTag extends BodyTagSupport { 20 21 private int id = 0; 22 23 public void setId(int id) { 24 this.id = id; 25 } 26 27 public int doStartTag() { 28 29 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 30 JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData"); 31 if ( this.id == jData.params().getPageID() ) { 32 return EVAL_BODY_BUFFERED; 33 } 34 return SKIP_BODY; 35 } 36 37 38 public int doAfterBody() { 39 try { 40 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 41 } catch (IOException ioe) { 42 JahiaConsole.println("IfPageIdIsTag: doAfterBody ",ioe.toString()); 43 } 44 return SKIP_BODY; 45 } 46 47 public int doEndTag() throws JspException { 48 id = 0; 51 return EVAL_PAGE; 52 } 53 54 } 55 | Popular Tags |