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.grid; 018 019import java.util.List; 020 021import org.apache.wicket.markup.repeater.data.IDataProvider; 022 023 024/** 025 * Simple concrete implementation of {@link AbstractDataGridView} 026 * 027 * <p> 028 * Example: 029 * 030 * <pre> 031 * <table> 032 * <tr wicket:id="rows"> 033 * <td wicket:id="cells"> 034 * <span wicket:id="cell"> </span> 035 * </td> 036 * </tr> 037 * </table> 038 * </pre> 039 * 040 * <p> 041 * Though this example is about a HTML table, DataGridView is not at all limited to HTML tables. Any 042 * kind of grid can be rendered using DataGridView. 043 * <p> 044 * And the related Java code: 045 * 046 * <pre> 047 * // Application specific POJO to view/edit 048 * public class MyEntity { 049 * private String firstName; 050 * private String lastName; 051 * 052 * // getters and setters 053 * } 054 * 055 * public class MyEntityProvider implements IDataProvider<MyEntity> { 056 * ... 057 * } 058 * 059 * List<ICellPopulator<MyEntity>> columns = new ArrayList<>(); 060 * 061 * columns.add(new PropertyPopulator<MyEntity>("firstName")); 062 * columns.add(new PropertyPopulator<MyEntity>("lastName")); 063 * 064 * add(new DataGridView<MyEntity>("rows", columns, new MyEntityProvider())); 065 * 066 * </pre> 067 * 068 * @see AbstractDataGridView 069 * @see IDataProvider 070 * 071 * @author Igor Vaynberg (ivaynberg) 072 * 073 * @param <T> 074 * Model object type 075 */ 076public class DataGridView<T> extends AbstractDataGridView<T> 077{ 078 private static final long serialVersionUID = 1L; 079 080 /** 081 * Constructor 082 * 083 * Notice cells are created in the same order as cell populators in the list 084 * 085 * @param id 086 * component id 087 * @param populators 088 * list of ICellPopulators used to populate cells 089 * @param dataProvider 090 * data provider 091 */ 092 public DataGridView(final String id, final List<? extends ICellPopulator<T>> populators, 093 final IDataProvider<T> dataProvider) 094 { 095 super(id, populators, dataProvider); 096 } 097 098 /** 099 * Returns the list of cell populators 100 * 101 * @return the list of cell populators 102 */ 103 public List<? extends ICellPopulator<T>> getPopulators() 104 { 105 return internalGetPopulators(); 106 } 107 108 /** 109 * Returns the data provider 110 * 111 * @return data provider 112 */ 113 public IDataProvider<T> getDataProvider() 114 { 115 return internalGetDataProvider(); 116 } 117 118 119}