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