KickJava   Java API By Example, From Geeks To Geeks.

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


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

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