KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jahia.deprecated.taglibs.container;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import org.jahia.data.JahiaData;
6 import org.jahia.data.containers.JahiaContainerList;
7 import org.jahia.exceptions.JahiaException;
8 import org.jahia.utils.JahiaConsole;
9
10
11
12 /**
13  * Class AbsoluteContainerListTag : extends class ContainerListTag
14  *
15  * An absolute container list is declared on a page and can be used on any page
16  *
17  * @author Jerome Tamiotti
18  */

19 public class AbsoluteContainerListTag extends ContainerListTag {
20
21     private int pageId = -1;
22     private int pageLevel = -1;
23     private int windowSize = -1;
24     private int windowOffset = -1;
25
26     public void setPageId(String JavaDoc pageId) {
27         try {
28             this.pageId = Integer.parseInt(pageId);
29         } catch (NumberFormatException JavaDoc nfe) {
30             JahiaConsole.println("AbsoluteContainerListTag: setPageId", "The given page id is not a number");
31         }
32     }
33
34     public void setPageLevel(String JavaDoc pageLevel) {
35         try {
36             this.pageLevel = Integer.parseInt(pageLevel);
37         } catch (NumberFormatException JavaDoc nfe) {
38             JahiaConsole.println("AbsoluteContainerListTag: setPageLevel", "The given page level is not a number");
39         }
40     }
41
42     public void setWindowSize(String JavaDoc windowSize) {
43         try {
44             this.windowSize = Integer.parseInt(windowSize);
45         } catch (NumberFormatException JavaDoc nfe) {
46             this.windowSize = -1;
47         }
48     }
49
50     /*
51     public int getWindowSize() {
52         return this.windowSize;
53     }
54     */

55
56     public void setWindowOffset(String JavaDoc windowOffset) {
57         try {
58             this.windowOffset = Integer.parseInt(windowOffset);
59         } catch (NumberFormatException JavaDoc nfe) {
60             this.windowOffset = -1;
61         }
62     }
63
64     /*
65     public int getWindowOffset() {
66         return this.windowOffset;
67     }
68     */

69
70     protected void checkAttributes(JahiaData jData) throws JahiaException {
71         if (this.pageId == -1) {
72             // check for page level
73
if (this.pageLevel != -1) {
74                 this.pageId = jData.gui().getLevelID(this.pageLevel);
75                 if (this.pageId == -1) {
76                     JahiaConsole.println("AbsoluteContainerListTag.checkAttributes",
77                                          "Couldn't find pageID for pageLevel=" + this.pageLevel);
78                 }
79             }
80         }
81     }
82
83     protected void checkDeclaration(JahiaData jData) throws JahiaException {
84         if ( jData.page().getID()== this.pageId ) {
85             jData.containers().declareContainer(super.getName(), super.getTitle(), super.getFields(), this.windowSize, this.windowOffset);
86         }
87     }
88
89
90     // redefines only the method allowing to read the container list
91

92     // reads the container list from a container set
93
protected JahiaContainerList getContainerList( JahiaData jData, String JavaDoc listName ) throws JahiaException {
94         return jData.containers().getAbsoluteContainerList( listName, this.pageId );
95     }
96
97     public int doEndTag() throws JspException JavaDoc {
98         // let's reinitialize the tag variables to allow tag object reuse in
99
// pooling.
100
super.doEndTag();
101         pageId = -1;
102         pageLevel = -1;
103         windowSize = -1;
104         windowOffset = -1;
105         return EVAL_PAGE;
106     }
107
108
109 }
110
Popular Tags