org.apache.wicket.markup.repeater.data
Interface IDataProvider<T>

Type Parameters:
T -
All Superinterfaces:
IClusterable, IDetachable, Serializable
All Known Subinterfaces:
ISortableDataProvider<T,S>, ITreeDataProvider<T>
All Known Implementing Classes:
ContactDataProvider, ContactDataProvider, EmptyDataProvider, ListDataProvider, ProxyDataProvider, SortableContactDataProvider, SortableDataProvider, TreeDataProvider

public interface IDataProvider<T>
extends IDetachable

Interface used to provide data to data views. Example:

 class UsersProvider implements IDataProvider
 {
 
        public Iterator iterator(int first, int count)
        {
                ((MyApplication)Application.get()).getUserDao().iterator(first, count);
        }
 
        public int size()
        {
                ((MyApplication)Application.get()).getUserDao().getCount();
        }
 
        public IModel model(Object object)
        {
                return new DetachableUserModel((User)object);
        }
 }
 
You can use the IDetachable.detach() method for cleaning up your IDataProvider instance. So that you can do one query that returns both the size and the values if your dataset is small enough the be able to do that.

Author:
Igor Vaynberg (ivaynberg)
See Also:
IDetachable, DataViewBase, DataView, GridView

Method Summary
 Iterator<? extends T> iterator(long first, long count)
          Gets an iterator for the subset of total data
 IModel<T> model(T object)
          Callback used by the consumer of this data provider to wrap objects retrieved from iterator(long, long) with a model (usually a detachable one).
 long size()
          Gets total number of items in the collection represented by the DataProvider
 
Methods inherited from interface org.apache.wicket.model.IDetachable
detach
 

Method Detail

iterator

Iterator<? extends T> iterator(long first,
                               long count)
Gets an iterator for the subset of total data

Parameters:
first - first row of data
count - minimum number of elements to retrieve
Returns:
iterator capable of iterating over {first, first+count} items

size

long size()
Gets total number of items in the collection represented by the DataProvider

Returns:
total item count

model

IModel<T> model(T object)
Callback used by the consumer of this data provider to wrap objects retrieved from iterator(long, long) with a model (usually a detachable one).

Parameters:
object - the object that needs to be wrapped
Returns:
the model representation of the object


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.