KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > taglibs > pagination > CListPaginationPageUrlTag


1 package org.jahia.taglibs.pagination;
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.data.containers.JahiaContainerListPagination;
8 import org.jahia.exceptions.JahiaException;
9 import org.jahia.taglibs.button.AbstractButtonTag;
10 import org.jahia.taglibs.container.ContainerListTag;
11
12 /**
13  * Get the page number returned from the enclosing
14  * CListPaginationTag.getPageNumber() and generate the URL for this page number.
15  *
16  * @author NK
17  * @version 1.0
18  */

19
20 public class CListPaginationPageUrlTag extends AbstractButtonTag {
21
22     private JahiaContainerList containerList = null;
23     private JahiaContainerListPagination cPagination = null;
24     private CListPaginationTag cPaginationTag = null;
25
26     private String JavaDoc title = "";
27     private String JavaDoc style = "";
28     private String JavaDoc method = "get";
29     private String JavaDoc formName = "";
30
31     public void setTitle(String JavaDoc title) {
32         this.title = title;
33     }
34
35     public void setStyle(String JavaDoc style) {
36         this.style = style;
37     }
38
39     public void setMethod(String JavaDoc method) {
40         if ( method != null )
41         {
42             this.method = method;
43         }
44     }
45
46     public void setFormName(String JavaDoc formName) {
47         if ( formName != null )
48         {
49             this.formName = formName.trim();
50         }
51     }
52
53     public String JavaDoc getTitle() {
54         return this.title;
55     }
56
57     public String JavaDoc getStyle() {
58         return this.style;
59     }
60
61     public String JavaDoc getMethod() {
62         return this.method;
63     }
64
65     public String JavaDoc getFormName() {
66         return this.formName;
67     }
68
69     public boolean testRights (JahiaData jData) {
70         cPaginationTag = (CListPaginationTag) findAncestorWithClass(this,CListPaginationTag.class);
71         if ( cPaginationTag == null ){
72             return false;
73         }
74         ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class);
75         if (parent != null) {
76             this.containerList = parent.getContainerList();
77             if ( this.containerList != null ){
78                 this.cPagination = this.containerList.getCtnListPagination();
79                 if ( this.cPagination != null && this.cPagination.isValid())
80                 {
81                     return true;
82                 }
83             }
84         }
85         return false;
86     }
87
88     public String JavaDoc getLauncher(JahiaData jData) throws JahiaException {
89         this.title = String.valueOf(cPaginationTag.getPageNumber());
90
91         String JavaDoc value = jData.gui().drawContainerListWindowPageURL( containerList, cPaginationTag.getPageNumber(), this.method.equals("post") );
92         if ( value != null && this.method.equals("post") )
93         {
94             StringBuffer JavaDoc buff = new StringBuffer JavaDoc("javascript:changePage(document.");
95             buff.append(getFormName());
96             buff.append(",document.");
97             buff.append(getFormName());
98             buff.append(".ctnscroll_");
99             buff.append(containerList.getDefinition().getName());
100             buff.append(",'");
101             buff.append(value);
102             buff.append("');");
103             value = buff.toString();
104         }
105         return value;
106     }
107
108     public int doEndTag() throws JspException JavaDoc {
109         // let's reinitialize the tag variables to allow tag object reuse in
110
// pooling.
111
containerList = null;
112         cPagination = null;
113         cPaginationTag = null;
114
115         title = "";
116         style = "";
117         method = "get";
118         formName = "";
119         return EVAL_PAGE;
120     }
121
122 }
Popular Tags