1 package org.jahia.deprecated.taglibs.field.page; 2 3 import java.io.IOException ; 4 import java.util.Enumeration ; 5 6 import javax.servlet.ServletRequest ; 7 import javax.servlet.jsp.tagext.BodyTagSupport ; 8 9 import org.jahia.data.JahiaData; 10 import org.jahia.exceptions.JahiaException; 11 import org.jahia.services.pages.JahiaPage; 12 import org.jahia.utils.JahiaConsole; 13 14 15 23 public class IfNotPageInPathTag extends BodyTagSupport { 24 25 public int doStartTag() { 26 27 PageFieldTag parent = (PageFieldTag) findAncestorWithClass(this, PageFieldTag.class); 29 if (parent == null) { 30 return SKIP_BODY; 31 } 32 JahiaPage thePage = parent.getPage(); 33 if (thePage != null) { 34 35 ServletRequest request = pageContext.getRequest(); 36 JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData"); 37 try { 39 Enumeration thePath = jData.page().getPagePath(jData.params().getOperationMode(), jData.params().getUser()); 40 while (thePath.hasMoreElements()) { 41 JahiaPage aPage = (JahiaPage) thePath.nextElement(); 42 if (aPage.getID() == thePage.getID()) { 43 return SKIP_BODY; 44 } 45 } 46 } catch (JahiaException je) { 47 JahiaConsole.println("IfNotPageInPathTag: doStartTag ",je.toString()); 48 } 49 return EVAL_BODY_BUFFERED; 50 } else { 51 return SKIP_BODY; 52 } 53 } 54 55 56 public int doAfterBody() { 57 try { 58 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 59 } catch (IOException ioe) { 60 JahiaConsole.println("IfNotPageInPathTag: doAfterBody ",ioe.toString()); 61 } 62 return SKIP_BODY; 63 } 64 65 } 66 | Popular Tags |