KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > datascroller > HtmlDataScroller


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.custom.datascroller;
17
18 import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
19
20 import javax.faces.component.UIComponent;
21 import javax.faces.context.FacesContext;
22 import javax.faces.el.ValueBinding;
23
24 /**
25  * @author Thomas Spiegl (latest modification by $Author: svieujot $)
26  * @version $Revision: 1.9 $ $Date: 2005/01/04 00:28:07 $
27  */

28 public class HtmlDataScroller
29         extends HtmlPanelGroup
30 {
31     //private static final Log log = LogFactory.getLog(HtmlPanelTabbedPane.class);
32

33     private static final String JavaDoc FIRST_FACET_NAME = "first";
34     private static final String JavaDoc LAST_FACET_NAME = "last";
35     private static final String JavaDoc NEXT_FACET_NAME = "next";
36     private static final String JavaDoc PREVIOUS_FACET_NAME = "previous";
37     private static final String JavaDoc FAST_FORWARD_FACET_NAME = "fastforward";
38     private static final String JavaDoc FAST_REWIND_FACET_NAME = "fastrewind";
39
40     public void setFirst(UIComponent first)
41     {
42         getFacets().put(FIRST_FACET_NAME, first);
43     }
44
45     public UIComponent getFirst()
46     {
47         return (UIComponent)getFacets().get(FIRST_FACET_NAME);
48     }
49
50     public void setLast(UIComponent last)
51     {
52         getFacets().put(LAST_FACET_NAME, last);
53     }
54
55     public UIComponent getLast()
56     {
57         return (UIComponent)getFacets().get(LAST_FACET_NAME);
58     }
59
60     public void setNext(UIComponent next)
61     {
62         getFacets().put(NEXT_FACET_NAME, next);
63     }
64
65     public UIComponent getNext()
66     {
67         return (UIComponent)getFacets().get(NEXT_FACET_NAME);
68     }
69
70     public void setFastForward(UIComponent previous)
71     {
72         getFacets().put(FAST_FORWARD_FACET_NAME, previous);
73     }
74
75     public UIComponent getFastForward()
76     {
77         return (UIComponent)getFacets().get(FAST_FORWARD_FACET_NAME);
78     }
79
80     public void setFastRewind(UIComponent previous)
81     {
82         getFacets().put(FAST_REWIND_FACET_NAME, previous);
83     }
84
85     public UIComponent getFastRewind()
86     {
87         return (UIComponent)getFacets().get(FAST_REWIND_FACET_NAME);
88     }
89
90     public void setPrevoius(UIComponent previous)
91     {
92         getFacets().put(PREVIOUS_FACET_NAME, previous);
93     }
94
95     public UIComponent getPrevious()
96     {
97         return (UIComponent)getFacets().get(PREVIOUS_FACET_NAME);
98     }
99
100
101     public boolean getRendersChildren()
102     {
103         return true;
104     }
105
106
107     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
108

109     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlDataScroller";
110     public static final String JavaDoc COMPONENT_FAMILY = "javax.faces.Panel";
111     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.DataScroller";
112
113     private String JavaDoc _for = null;
114     private Integer JavaDoc _fastStep = null;
115     private String JavaDoc _pageIndexVar = null;
116     private String JavaDoc _pageCountVar = null;
117     private String JavaDoc _rowsCountVar = null;
118     private String JavaDoc _displayedRowsCountVar = null;
119     private String JavaDoc _firstRowIndexVar = null;
120     private String JavaDoc _lastRowIndexVar = null;
121     private String JavaDoc _style = null;
122     private String JavaDoc _styleClass = null;
123     private String JavaDoc _columnClasses = null;
124     private Boolean JavaDoc _paginator = null;
125     private Integer JavaDoc _paginatorMaxPages = null;
126     private String JavaDoc _paginatorTableClass = null;
127     private String JavaDoc _paginatorTableStyle = null;
128     private String JavaDoc _paginatorColumnClass = null;
129     private String JavaDoc _paginatorColumnStyle = null;
130     private String JavaDoc _paginatorActiveColumnClass = null;
131     private String JavaDoc _paginatorActiveColumnStyle = null;
132
133     public HtmlDataScroller()
134     {
135         setRendererType(DEFAULT_RENDERER_TYPE);
136     }
137
138     public String JavaDoc getFamily()
139     {
140         return COMPONENT_FAMILY;
141     }
142
143     public void setFor(String JavaDoc forValue)
144     {
145         _for = forValue;
146     }
147
148     public String JavaDoc getFor()
149     {
150         if (_for != null) return _for;
151         ValueBinding vb = getValueBinding("for");
152         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
153     }
154
155     public void setFastStep(int fastStep)
156     {
157         _fastStep = new Integer JavaDoc(fastStep);
158     }
159
160     public int getFastStep()
161     {
162         if (_fastStep != null) return _fastStep.intValue();
163         ValueBinding vb = getValueBinding("fastStep");
164         Integer JavaDoc v = vb != null ? (Integer JavaDoc)vb.getValue(getFacesContext()) : null;
165         return v != null ? v.intValue() : Integer.MIN_VALUE;
166     }
167
168     public void setPageIndexVar(String JavaDoc pageIndexVar)
169     {
170         _pageIndexVar = pageIndexVar;
171     }
172
173     public String JavaDoc getPageIndexVar()
174     {
175         if (_pageIndexVar != null) return _pageIndexVar;
176         ValueBinding vb = getValueBinding("pageIndexVar");
177         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
178     }
179
180     public void setPageCountVar(String JavaDoc pageCountVar)
181     {
182         _pageCountVar = pageCountVar;
183     }
184
185     public String JavaDoc getPageCountVar()
186     {
187         if (_pageCountVar != null) return _pageCountVar;
188         ValueBinding vb = getValueBinding("pageCountVar");
189         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
190     }
191     
192     public void setRowsCountVar(String JavaDoc rowsCountVar)
193     {
194         _rowsCountVar = rowsCountVar;
195     }
196
197     public String JavaDoc getRowsCountVar()
198     {
199         if (_rowsCountVar != null) return _rowsCountVar;
200         ValueBinding vb = getValueBinding("rowsCountVar");
201         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
202     }
203     
204     public void setDisplayedRowsCountVar(String JavaDoc displayedRowsCountVar)
205     {
206         _displayedRowsCountVar = displayedRowsCountVar;
207     }
208     
209     public String JavaDoc getDisplayedRowsCountVar()
210     {
211         if (_displayedRowsCountVar != null) return _displayedRowsCountVar;
212         ValueBinding vb = getValueBinding("displayedRowsCountVar");
213         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
214     }
215     
216     public void setFirstRowIndexVar(String JavaDoc firstRowIndexVar)
217     {
218         _firstRowIndexVar = firstRowIndexVar;
219     }
220
221     public String JavaDoc getFirstRowIndexVar()
222     {
223         if (_firstRowIndexVar != null) return _firstRowIndexVar;
224         ValueBinding vb = getValueBinding("firstRowIndexVar");
225         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
226     }
227
228     public void setLastRowIndexVar(String JavaDoc lastRowIndexVar)
229     {
230         _lastRowIndexVar = lastRowIndexVar;
231     }
232
233     public String JavaDoc getLastRowIndexVar()
234     {
235         if (_lastRowIndexVar != null) return _lastRowIndexVar;
236         ValueBinding vb = getValueBinding("lastRowIndexVar");
237         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
238     }
239     
240     public void setStyle(String JavaDoc style)
241     {
242         _style = style;
243     }
244
245     public String JavaDoc getStyle()
246     {
247         if (_style != null) return _style;
248         ValueBinding vb = getValueBinding("style");
249         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
250     }
251
252     public void setStyleClass(String JavaDoc styleClass)
253     {
254         _styleClass = styleClass;
255     }
256
257     public String JavaDoc getStyleClass()
258     {
259         if (_styleClass != null) return _styleClass;
260         ValueBinding vb = getValueBinding("styleClass");
261         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
262     }
263
264     public void setPaginator(boolean paginator)
265     {
266         _paginator = Boolean.valueOf(paginator);
267     }
268
269     public boolean isPaginator()
270     {
271         if (_paginator != null) return _paginator.booleanValue();
272         ValueBinding vb = getValueBinding("paginator");
273         Boolean JavaDoc v = vb != null ? (Boolean JavaDoc)vb.getValue(getFacesContext()) : null;
274         return v != null ? v.booleanValue() : false;
275     }
276
277     public void setPaginatorMaxPages(int paginatorMaxPages)
278     {
279         _paginatorMaxPages = new Integer JavaDoc(paginatorMaxPages);
280     }
281
282     public int getPaginatorMaxPages()
283     {
284         if (_paginatorMaxPages != null) return _paginatorMaxPages.intValue();
285         ValueBinding vb = getValueBinding("paginatorMaxPages");
286         Integer JavaDoc v = vb != null ? (Integer JavaDoc)vb.getValue(getFacesContext()) : null;
287         return v != null ? v.intValue() : Integer.MIN_VALUE;
288     }
289
290     public void setPaginatorTableClass(String JavaDoc paginatorTableClass)
291     {
292         _paginatorTableClass = paginatorTableClass;
293     }
294
295     public String JavaDoc getPaginatorTableClass()
296     {
297         if (_paginatorTableClass != null) return _paginatorTableClass;
298         ValueBinding vb = getValueBinding("paginatorTableClass");
299         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
300     }
301
302     public void setPaginatorTableStyle(String JavaDoc paginatorTableStyle)
303     {
304         _paginatorTableStyle = paginatorTableStyle;
305     }
306
307     public String JavaDoc getPaginatorTableStyle()
308     {
309         if (_paginatorTableStyle != null) return _paginatorTableStyle;
310         ValueBinding vb = getValueBinding("paginatorTableStyle");
311         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
312     }
313
314     public void setPaginatorColumnClass(String JavaDoc paginatorColumnClass)
315     {
316         _paginatorColumnClass = paginatorColumnClass;
317     }
318
319     public String JavaDoc getPaginatorColumnClass()
320     {
321         if (_paginatorColumnClass != null) return _paginatorColumnClass;
322         ValueBinding vb = getValueBinding("paginatorColumnClass");
323         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
324     }
325
326     public void setPaginatorColumnStyle(String JavaDoc paginatorColumnStyle)
327     {
328         _paginatorColumnStyle = paginatorColumnStyle;
329     }
330
331     public String JavaDoc getPaginatorColumnStyle()
332     {
333         if (_paginatorColumnStyle != null) return _paginatorColumnStyle;
334         ValueBinding vb = getValueBinding("paginatorColumnStyle");
335         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
336     }
337
338     public void setPaginatorActiveColumnClass(String JavaDoc paginatorActiveColumnClass)
339     {
340         _paginatorActiveColumnClass = paginatorActiveColumnClass;
341     }
342
343     public String JavaDoc getPaginatorActiveColumnClass()
344     {
345         if (_paginatorActiveColumnClass != null) return _paginatorActiveColumnClass;
346         ValueBinding vb = getValueBinding("paginatorActiveColumnClass");
347         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
348     }
349
350     public void setPaginatorActiveColumnStyle(String JavaDoc paginatorActiveColumnStyle)
351     {
352         _paginatorActiveColumnStyle = paginatorActiveColumnStyle;
353     }
354
355     public String JavaDoc getPaginatorActiveColumnStyle()
356     {
357         if (_paginatorActiveColumnStyle != null) return _paginatorActiveColumnStyle;
358         ValueBinding vb = getValueBinding("paginatorActiveColumnStyle");
359         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
360     }
361
362
363
364     public Object JavaDoc saveState(FacesContext context)
365     {
366         Object JavaDoc values[] = new Object JavaDoc[20];
367         values[0] = super.saveState(context);
368         values[1] = _for;
369         values[2] = _fastStep;
370         values[3] = _pageIndexVar;
371         values[4] = _pageCountVar;
372         values[5] = _rowsCountVar;
373         values[6] = _displayedRowsCountVar;
374         values[7] = _firstRowIndexVar;
375         values[8] = _lastRowIndexVar;
376         values[9] = _style;
377         values[10] = _styleClass;
378         values[11] = _columnClasses;
379         values[12] = _paginator;
380         values[13] = _paginatorMaxPages;
381         values[14] = _paginatorTableClass;
382         values[15] = _paginatorTableStyle;
383         values[16] = _paginatorColumnClass;
384         values[17] = _paginatorColumnStyle;
385         values[18] = _paginatorActiveColumnClass;
386         values[19] = _paginatorActiveColumnStyle;
387         return values;
388     }
389
390     public void restoreState(FacesContext context, Object JavaDoc state)
391     {
392         Object JavaDoc values[] = (Object JavaDoc[])state;
393         super.restoreState(context, values[0]);
394         _for = (String JavaDoc)values[1];
395         _fastStep = (Integer JavaDoc)values[2];
396         _pageIndexVar = (String JavaDoc)values[3];
397         _pageCountVar = (String JavaDoc)values[4];
398         _rowsCountVar = (String JavaDoc)values[5];
399         _displayedRowsCountVar = (String JavaDoc)values[6];
400         _firstRowIndexVar = (String JavaDoc)values[7];
401         _lastRowIndexVar = (String JavaDoc)values[8];
402         _style = (String JavaDoc)values[9];
403         _styleClass = (String JavaDoc)values[10];
404         _columnClasses = (String JavaDoc)values[11];
405         _paginator = (Boolean JavaDoc)values[12];
406         _paginatorMaxPages = (Integer JavaDoc)values[13];
407         _paginatorTableClass = (String JavaDoc)values[14];
408         _paginatorTableStyle = (String JavaDoc)values[15];
409         _paginatorColumnClass = (String JavaDoc)values[16];
410         _paginatorColumnStyle = (String JavaDoc)values[17];
411         _paginatorActiveColumnClass = (String JavaDoc)values[18];
412         _paginatorActiveColumnStyle = (String JavaDoc)values[19];
413     }
414     //------------------ GENERATED CODE END ---------------------------------------
415
}
416
Popular Tags