KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jahia.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  * Class AbsoluteContainerListTag : extends class ContainerListTag
12  *
13  * An absolute container list is declared on a page and can be used on any page
14  *
15  * @author Jerome Tamiotti
16  */

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

53
54     public void setWindowOffset(String JavaDoc windowOffset) {
55         try {
56             this.windowOffset = Integer.parseInt(windowOffset);
57         } catch (NumberFormatException JavaDoc nfe) {
58             this.windowOffset = -1;
59         }
60     }
61
62     // redefines only the method allowing to read the container list
63

64     // reads the container list from a container set
65
protected JahiaContainerList getContainerList( JahiaData jData, String JavaDoc listName ) throws JahiaException {
66         if ((this.pageId == -1) && (this.pageLevel != -1)) {
67             this.pageId = jData.gui().getLevelID(this.pageLevel);
68         }
69         return jData.containers().getAbsoluteContainerList( listName, this.pageId );
70     }
71
72     public int doEndTag() throws JspException JavaDoc {
73         // let's reinitialize the tag variables to allow tag object reuse in
74
// pooling.
75
super.doEndTag();
76         pageId = -1;
77         pageLevel = -1;
78         windowSize = -1;
79         windowOffset = -1;
80         return EVAL_PAGE;
81     }
82
83
84 }
85
Popular Tags