KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > icefaces > samples > showcase > components > table > TableBean


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33
34 package com.icesoft.icefaces.samples.showcase.components.table;
35
36 import com.icesoft.faces.component.ext.RowSelectorEvent;
37 import com.icesoft.icefaces.samples.showcase.common.Person;
38
39 import javax.faces.event.ValueChangeEvent;
40 import javax.faces.event.ActionEvent;
41 import java.util.ArrayList JavaDoc;
42 import java.util.List JavaDoc;
43
44 /**
45  * <p>The TableBean class is the backing bean for the table Component showcase
46  * demonstration. It is used to store the visibility state of the four data
47  * columns used in the demonstration.</p>
48  *
49  * @since 0.3.0
50  */

51 public class TableBean {
52
53     // column visibility, true to render false otherwise.
54
private boolean renderFirstName = true;
55     private boolean renderLastName = true;
56     private boolean renderPhone = true;
57     private boolean renderEmail = true;
58     private List JavaDoc selectedRows = new ArrayList JavaDoc();
59     private boolean multipleSelection = true;
60     // enable scrollable property
61
private boolean scrollable = true;
62     // scrollable height property;
63
private String JavaDoc scrollableHeight = "100px";
64     private Person[] personsList = DataTablePaginatorBean.buildPersonList();
65
66     public TableBean() {
67     }
68
69     /**
70      * Is the first name column rendered?
71      *
72      * @return rendered state of column
73      */

74     public boolean isRenderFirstName() {
75         return renderFirstName;
76     }
77
78     /**
79      * Sets the first name column rendered state.
80      *
81      * @param renderFirstName true to render column; false otherwise
82      */

83     public void setRenderFirstName(boolean renderFirstName) {
84         this.renderFirstName = renderFirstName;
85     }
86
87     /**
88      * Is the last name column rendered?
89      *
90      * @return rendered state of column
91      */

92     public boolean isRenderLastName() {
93         return renderLastName;
94     }
95
96     /**
97      * Sets the last name column rendered state.
98      *
99      * @param renderLastName true to render column; false otherwise
100      */

101     public void setRenderLastName(boolean renderLastName) {
102         this.renderLastName = renderLastName;
103     }
104
105     /**
106      * Is the phone column rendered?
107      *
108      * @return rendered state of column
109      */

110     public boolean isRenderPhone() {
111         return renderPhone;
112     }
113
114     /**
115      * Sets the phone column rendered state.
116      *
117      * @param renderPhone true to render column; false otherwise
118      */

119     public void setRenderPhone(boolean renderPhone) {
120         this.renderPhone = renderPhone;
121     }
122
123     /**
124      * Is the email column rendered?
125      *
126      * @return rendered state of column
127      */

128     public boolean isRenderEmail() {
129         return renderEmail;
130     }
131
132     /**
133      * Sets the email column rendered state.
134      *
135      * @param renderEmail true to render column; false otherwise
136      */

137     public void setRenderEmail(boolean renderEmail) {
138         this.renderEmail = renderEmail;
139     }
140
141     public List JavaDoc getSelectedRows() {
142
143         return selectedRows;
144     }
145
146     public void setSelectedRows(List JavaDoc selectedRows) {
147         this.selectedRows = selectedRows;
148     }
149
150
151     public void rowSelection(RowSelectorEvent e) {
152         selectedRows.clear();
153         for (int i = personsList.length-1; i >= 0 ; i--) {
154             if (personsList[i].getSelected().booleanValue()) {
155                 selectedRows.add(personsList[i]);
156             }
157         }
158     }
159
160     public void clearSelections(ActionEvent event){
161         selectedRows.clear();
162          for (int i = personsList.length-1; i >= 0 ; i--) {
163             personsList[i].setSelected(new Boolean JavaDoc(false));
164         }
165     }
166
167     public boolean isMultipleSelection() {
168         return multipleSelection;
169     }
170
171     public void setMultipleSelection(boolean multipleSelection) {
172         this.multipleSelection = multipleSelection;
173     }
174
175     public void selectionChanged(ValueChangeEvent event) {
176
177         selectedRows.clear();
178         Person[] persons = personsList;
179         for (int i = 0; i < persons.length; i++) {
180             persons[i].setSelected(Boolean.FALSE);
181         }
182
183     }
184
185     public boolean isScrollable() {
186         return scrollable;
187     }
188
189     public void setScrollable(boolean scrollable) {
190         this.scrollable = scrollable;
191     }
192
193     public Person[] getPersonsList() {
194         return personsList;
195     }
196
197     public void setPersonsList(Person[] personsList) {
198         this.personsList = personsList;
199     }
200
201
202     public String JavaDoc getScrollableHeight() {
203         return scrollableHeight;
204     }
205     public void setScrollableHeight(String JavaDoc scrollableHeight) {
206         this.scrollableHeight = scrollableHeight;
207     }
208 }
Popular Tags