KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > container > IfContainerPositionTag


1 package org.jahia.deprecated.taglibs.container;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.jsp.JspWriter JavaDoc;
6 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
7 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
8
9 import org.jahia.utils.JahiaConsole;
10
11
12 /**
13  * Class IfContainerPositionTag : evaluates the body if the current container
14  * is located at a wanted position in the list
15  *
16  * @author Jerome Tamiotti
17  */

18 public abstract class IfContainerPositionTag extends BodyTagSupport JavaDoc {
19
20     public int doAfterBody() {
21         // gets the parent tag ContainerTag
22
ContainerTag containerTag = (ContainerTag) findAncestorWithClass(this, ContainerTag.class);
23         if ( containerTag == null) {
24             return SKIP_BODY;
25         }
26         if ( containerTag.isDeclarationPass() ) {
27             return SKIP_BODY;
28         }
29         if ( isPositionGood(containerTag) ) {
30             // the current container is the first of the stack
31
try {
32                 BodyContent JavaDoc body = getBodyContent();
33                 JspWriter JavaDoc out = body.getEnclosingWriter();
34                 out.print(body.getString());
35             } catch (IOException JavaDoc ioe) {
36                 JahiaConsole.println("IfFirstContainerTag: doAfterBody ",ioe.toString());
37             }
38         }
39         return SKIP_BODY;
40     }
41
42     // will be implemented in the different test tags
43
public abstract boolean isPositionGood( ContainerTag containerTag );
44
45 }
46
Popular Tags