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