KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > button > PreviousWindowButtonTag


1 package org.jahia.deprecated.taglibs.button;
2
3 import java.util.Enumeration JavaDoc;
4
5 import javax.servlet.jsp.JspException JavaDoc;
6
7 import org.jahia.data.JahiaData;
8 import org.jahia.data.containers.JahiaContainerList;
9 import org.jahia.deprecated.taglibs.container.ContainerListTag;
10 import org.jahia.exceptions.JahiaException;
11 import org.jahia.services.usermanager.JahiaUser;
12
13 /**
14  * <p>Title: </p>
15  * <p>Description: </p>
16  * <p>Copyright: Copyright (c) 2002</p>
17  * <p>Company: Jahia Ltd</p>
18  * @author Serge Huber
19  * @version 1.0
20  */

21 // 05.05.2002 NK : Added Post method support
22

23 public class PreviousWindowButtonTag extends AbstractButtonTag {
24
25     private JahiaContainerList containerList = null;
26     private String JavaDoc title = "&lt;&lt;Previous";
27     private String JavaDoc style = "";
28     private String JavaDoc method = "get";
29     private String JavaDoc formName = "";
30
31     private int windowStepInt = 1;
32     private int windowSizeInt = -1;
33
34     // these are necessary since we must be JavaBean compliant.
35
private String JavaDoc windowStep;
36     private String JavaDoc windowSize;
37
38     public void setTitle(String JavaDoc title) {
39         this.title = title;
40     }
41
42     public void setStyle(String JavaDoc style) {
43         this.style = style;
44     }
45
46     public void setMethod(String JavaDoc method) {
47         if ( method != null )
48         {
49             this.method = method;
50         }
51     }
52
53     public void setFormName(String JavaDoc formName) {
54         if ( formName != null )
55         {
56             this.formName = formName.trim();
57         }
58     }
59
60     public void setWindowStep(String JavaDoc windowStep) {
61         this.windowStep = windowStep;
62         try {
63             windowStepInt = Integer.parseInt(windowStep);
64             if (windowStepInt < 0)
65               windowStepInt = 0;
66         } catch (NumberFormatException JavaDoc nfe) {
67             windowStepInt = 0;
68         }
69     }
70
71     public void setWindowSize(String JavaDoc windowSize) {
72         this.windowSize = windowSize;
73         try {
74             windowSizeInt = Integer.parseInt(windowSize);
75             if (windowSizeInt < 1)
76               windowSizeInt = -1;
77         } catch (NumberFormatException JavaDoc nfe) {
78             windowSizeInt = -1;
79         }
80     }
81
82     public String JavaDoc getTitle() {
83         return this.title;
84     }
85
86     public String JavaDoc getStyle() {
87         return this.style;
88     }
89
90     public String JavaDoc getMethod() {
91         return this.method;
92     }
93
94     public String JavaDoc getFormName() {
95         return this.formName;
96     }
97
98     public int getWindowStepInt() {
99         return this.windowStepInt;
100     }
101
102     public int getWindowSizeInt() {
103         return this.windowSizeInt;
104     }
105
106     public String JavaDoc getWindowStep() {
107         return this.windowStep;
108     }
109
110     public String JavaDoc getWindowSize() {
111         return this.windowSize;
112     }
113
114     public boolean testRights (JahiaData jData) {
115         JahiaUser user = jData.params().getUser();
116         // retrieves the current container list
117
ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class);
118         if (parent != null) {
119             if (parent.isDeclarationPass()) {
120                 return false;
121             }
122             containerList = parent.getContainerList();
123         }
124         if (containerList != null) {
125             Enumeration JavaDoc containers = containerList.getContainers();
126             return ( containers.hasMoreElements() );
127         }
128         return false;
129     }
130
131     public String JavaDoc getLauncher(JahiaData jData) throws JahiaException {
132         String JavaDoc value = jData.gui().drawContainerListPreviousWindowPageURL( containerList, windowStepInt, windowSizeInt, this.method.equals("post") );
133         if ( value != null && this.method.equals("post") )
134         {
135             StringBuffer JavaDoc buff = new StringBuffer JavaDoc("javascript:changePage(document.");
136             buff.append(getFormName());
137             buff.append(",document.");
138             buff.append(getFormName());
139             buff.append(".ctnscroll_");
140             buff.append(containerList.getDefinition().getName());
141             buff.append(",'");
142             buff.append(value);
143             buff.append("');");
144             value = buff.toString();
145         }
146
147         return value;
148     }
149
150     public int doEndTag() throws JspException JavaDoc {
151         // let's reinitialize the tag variables to allow tag object reuse in
152
// pooling.
153
containerList = null;
154         title = "&lt;&lt;Previous";
155         style = "";
156         method = "get";
157         formName = "";
158
159         windowStepInt = 1;
160         windowSizeInt = -1;
161
162         windowStep = null;
163         windowSize = null;
164         return EVAL_PAGE;
165     }
166
167
168 }
Popular Tags