01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/jsf/tags/sakai_2-4-1/example/src/java/example/PagerBean.java $
03: * $Id: PagerBean.java 9278 2006-05-10 23:29:21Z ray@media.berkeley.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package example;
21:
22: import java.io.PrintStream;
23: import java.util.ArrayList;
24:
25: import javax.faces.event.AbortProcessingException;
26: import javax.faces.event.ValueChangeEvent;
27:
28: /**
29: * Example backing bean for the pager widget
30: */
31: public class PagerBean {
32: private static final PrintStream out = System.out;
33: private int totalItems;
34: private int firstItem;
35: private int pageSize;
36: private ArrayList data;
37:
38: public PagerBean() {
39: out.println("PagerBean()");
40: totalItems = 211;
41: firstItem = 50;
42: pageSize = 5;
43: initData();
44: }
45:
46: public int getFirstItem() {
47: out.println("PagerBean.getFirstItem()");
48: return firstItem;
49: }
50:
51: public void setFirstItem(int firstItem) {
52: out.println("PagerBean.setFirstItem()");
53: this .firstItem = firstItem;
54: }
55:
56: public int getPageSize() {
57: out.println("PagerBean.getPageSize()");
58: return pageSize;
59: }
60:
61: public void setPageSize(int pageSize) {
62: out.println("PagerBean.setPageSize()");
63: this .pageSize = pageSize;
64: }
65:
66: public int getTotalItems() {
67: out.println("PagerBean.getTotalItems()");
68: return totalItems;
69: }
70:
71: public void setTotalItems(int totalItems) {
72: out.println("PagerBean.setTotalItems()");
73: this .totalItems = totalItems;
74: }
75:
76: public void handleValueChange(ValueChangeEvent event)
77: throws AbortProcessingException {
78: out.println("PagerBean.processValueChange(): old value: "
79: + event.getOldValue() + " new value: "
80: + event.getNewValue());
81: }
82:
83: private void initData() {
84: data = new ArrayList();
85: for (int i = 0; i < totalItems; i++) {
86: data.add("Item #" + (i + 1));
87: }
88: }
89:
90: public ArrayList getData() {
91: out.println("PagerBean.getData()");
92: return data;
93: }
94: }
|