01: /*
02: * $Id: DefaultDataTable.java 458884 2006-01-30 21:56:23Z ivaynberg $
03: * $Revision: 458884 $ $Date: 2006-01-30 22:56:23 +0100 (Mon, 30 Jan 2006) $
04: *
05: * ==================================================================== Licensed
06: * under the Apache License, Version 2.0 (the "License"); you may not use this
07: * file except in compliance with the License. You may obtain a copy of the
08: * License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15: * License for the specific language governing permissions and limitations under
16: * the License.
17: */
18: package wicket.extensions.markup.html.repeater.data.table;
19:
20: import java.util.List;
21:
22: import wicket.extensions.markup.html.repeater.refreshing.Item;
23: import wicket.extensions.markup.html.repeater.refreshing.OddEvenItem;
24: import wicket.extensions.markup.html.repeater.util.SortableDataProvider;
25: import wicket.model.IModel;
26:
27: /**
28: * An implementation of the DataTable that aims to solve the 90% usecase by
29: * adding navigation, headers, an no-records-found toolbars to a standard
30: * {@link DataTable}.
31: * <p>
32: * The {@link NavigationToolbar} and the {@link HeadersToolbar} are added as top
33: * toolbars, while the {@link NoRecordsToolbar} toolbar is added as a bottom
34: * toolbar.
35: *
36: * @see DataTable
37: * @see HeadersToolbar
38: * @see NavigationToolbar
39: * @see NoRecordsToolbar
40: *
41: * @author Igor Vaynberg ( ivaynberg )
42: */
43: public class DefaultDataTable extends DataTable {
44: private static final long serialVersionUID = 1L;
45:
46: /**
47: * Constructor
48: *
49: * @param id
50: * component id
51: * @param columns
52: * list of columns
53: * @param dataProvider
54: * data provider
55: * @param rowsPerPage
56: * number of rows per page
57: */
58: public DefaultDataTable(String id,
59: final List/* <IColumn> */columns,
60: SortableDataProvider dataProvider, int rowsPerPage) {
61: this (id, (IColumn[]) columns
62: .toArray(new IColumn[columns.size()]), dataProvider,
63: rowsPerPage);
64: }
65:
66: /**
67: * Constructor
68: *
69: * @param id
70: * component id
71: * @param columns
72: * array of columns
73: * @param dataProvider
74: * data provider
75: * @param rowsPerPage
76: * number of rows per page
77: */
78: public DefaultDataTable(String id, final IColumn[] columns,
79: SortableDataProvider dataProvider, int rowsPerPage) {
80: super (id, columns, dataProvider, rowsPerPage);
81:
82: addTopToolbar(new NavigationToolbar(this ));
83: addTopToolbar(new HeadersToolbar(this , dataProvider));
84: addBottomToolbar(new NoRecordsToolbar(this ));
85: }
86:
87: protected Item newRowItem(String id, int index, IModel model) {
88: return new OddEvenItem(id, index, model);
89: }
90:
91: }
|