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.markup.repeater.data;
018
019import org.apache.wicket.markup.html.navigation.paging.IPageable;
020import org.apache.wicket.markup.repeater.AbstractPageableView;
021
022/**
023 * DataView is a basic implementation of {@link AbstractPageableView}.
024 * 
025 * Data views aim to make it very simple to populate your repeating view from a database by
026 * utilizing {@link IDataProvider} to act as an interface between the database and the dataview.
027 * 
028 * 
029 * 
030 * <p>
031 * Example:
032 * 
033 * <pre>
034 *     &lt;tbody&gt;
035 *       &lt;tr wicket:id=&quot;rows&quot;&gt;
036 *         &lt;td&gt;&lt;span wicket:id=&quot;id&quot;&gt;Test ID&lt;/span&gt;&lt;/td&gt;
037 *         ...
038 * </pre>
039 * 
040 * <p>
041 * Though this example is about a HTML table, DataView is not at all limited to HTML tables. Any
042 * kind of list can be rendered using DataView.
043 * <p>
044 * And the related Java code:
045 * 
046 * <pre>
047 * add(new DataView&lt;UserDetails&gt;(&quot;rows&quot;, dataProvider)
048 * {
049 *      public void populateItem(final Item&lt;UserDetails&gt; item)
050 *      {
051 *              final UserDetails user = item.getModelObject();
052 *              item.add(new Label(&quot;id&quot;, user.getId()));
053 *      }
054 * });
055 * </pre>
056 * 
057 * @see IDataProvider
058 * @see IPageable
059 * 
060 * @author Igor Vaynberg (ivaynberg)
061 * 
062 * @param <T>
063 *            The Model type.
064 */
065public abstract class DataView<T> extends DataViewBase<T>
066{
067
068        /**
069         * 
070         */
071        private static final long serialVersionUID = 1L;
072
073        /**
074         * @param id
075         *            component id
076         * @param dataProvider
077         *            data provider
078         */
079        protected DataView(String id, IDataProvider<T> dataProvider)
080        {
081                super(id, dataProvider);
082        }
083
084        /**
085         * @param id
086         *            component id
087         * @param dataProvider
088         *            data provider
089         * @param itemsPerPage
090         *            items per page
091         */
092        protected DataView(String id, IDataProvider<T> dataProvider, long itemsPerPage)
093        {
094                super(id, dataProvider);
095                setItemsPerPage(itemsPerPage);
096        }
097
098        /**
099         * @return data provider
100         */
101        public IDataProvider<T> getDataProvider()
102        {
103                return internalGetDataProvider();
104        }
105
106}