001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.extensions.markup.html.repeater.data.table; 018 019import java.util.List; 020 021import org.apache.wicket.markup.repeater.Item; 022import org.apache.wicket.markup.repeater.OddEvenItem; 023import org.apache.wicket.model.IModel; 024 025 026/** 027 * An implementation of the DataTable that aims to solve the 90% usecase by adding navigation, 028 * headers, an no-records-found toolbars to a standard {@link DataTable}. 029 * <p> 030 * The {@link NavigationToolbar} and the {@link HeadersToolbar} are added as top toolbars, while the 031 * {@link NoRecordsToolbar} toolbar is added as a bottom toolbar. 032 * 033 * @see DataTable 034 * @see HeadersToolbar 035 * @see NavigationToolbar 036 * @see NoRecordsToolbar 037 * 038 * @author Igor Vaynberg ( ivaynberg ) 039 * @param <T> 040 * The model object type 041 * @param <S> 042 * the type of the sorting parameter 043 */ 044public class DefaultDataTable<T, S> extends DataTable<T, S> 045{ 046 private static final long serialVersionUID = 1L; 047 048 /** 049 * Constructor 050 * 051 * @param id 052 * component id 053 * @param columns 054 * list of columns 055 * @param dataProvider 056 * data provider 057 * @param rowsPerPage 058 * number of rows per page 059 */ 060 public DefaultDataTable(final String id, final List<? extends IColumn<T, S>> columns, 061 final ISortableDataProvider<T, S> dataProvider, final int rowsPerPage) 062 { 063 super(id, columns, dataProvider, rowsPerPage); 064 065 addTopToolbar(new NavigationToolbar(this)); 066 addTopToolbar(new HeadersToolbar<>(this, dataProvider)); 067 addBottomToolbar(new NoRecordsToolbar(this)); 068 } 069 070 @Override 071 protected Item<T> newRowItem(final String id, final int index, final IModel<T> model) 072 { 073 return new OddEvenItem<>(id, index, model); 074 } 075 076}