public class ListDataProvider<U extends org.ujorm.Ujo> extends AbstractDataProvider<U>
This class called ListDataProvider is a List based DataProvider.
For a customization you can use a your own IColumn implementations
or you can overwrite selected methods of this provider.
The implementation generates two database requests per a one rendering,
the first one get size and the second one get paged data. You can overwrite the two data methods:
iterator() and the size()
for more optimization.
The current class uses a WicketApplication implementation, which must
implement the interface OrmHandlerProvider for an ORM support. See the example:
Criterion<Hotel> allActiveHotels = Hotel.ACTIVE.whereEq(true);
UjoDataProvider<Hotel> dataProvider = UjoDataProvider.of(allActiveHotels);
dataProvider.addColumn(Hotel.NAME);
dataProvider.addColumn(Hotel.CITY.add(City.NAME)); // An example of relations
dataProvider.addColumn(Hotel.STREET);
dataProvider.addColumn(Hotel.PRICE);
dataProvider.addColumn(KeyColumn.of(Hotel.CURRENCY, SORTING_OFF));
dataProvider.addColumn(Hotel.STARS);
dataProvider.addColumn(Hotel.PHONE);
dataProvider.setSort(Hotel.NAME);
panel.add(dataProvider.createDataTable("datatable", 10));
DEFAULT_CSS_ACTION, DEFAULT_CSS_SELECTED, DEFAULT_DATATABLE_ID, filter, highlighting, size| Constructor and Description |
|---|
ListDataProvider(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> criterion)
Constructor
|
ListDataProvider(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> filter,
org.ujorm.Key<? super U,?> defaultSort)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearBuffer()
Clear a filter rows and size
|
long |
deleteRow(@NotNull org.ujorm.criterion.Criterion<? super U> deleteCondition)
Delete rows from the data source
|
void |
detach()
Detaches model after use.
|
protected @NotNull List<U> |
getFileredRows()
Returns a filtered rows and cach the result
|
@NotNull List<U> |
getRows()
Returns original data rows
|
boolean |
insertRow(U row)
Insert row to the data source
|
Iterator<U> |
iterator(long first,
long count)
Build a JDBC ResultSet always.
|
static <T extends org.ujorm.Ujo> |
of(org.ujorm.criterion.Criterion<? super T> criterion)
Factory for the class
|
static <T extends org.ujorm.Ujo> |
of(org.ujorm.criterion.Criterion<T> criterion,
org.ujorm.Key<? super T,?> defaultSort)
Factory for the class
|
static <T extends org.ujorm.Ujo> |
of(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<T>> criterion)
Factory for the class
|
static <T extends org.ujorm.Ujo> |
of(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<T>> criterion,
org.ujorm.Key<? super T,?> defaultSort)
Factory for the class
|
void |
setRows(List<? super U> dataRows)
Assign data resource
|
long |
size()
Method calculate the size of filtered rows
|
protected void |
sortRows(List<U> rows)
Sort the rows
|
long |
updateRow(@NotNull org.ujorm.criterion.Criterion<? super U> updateCondition,
U updatedRow)
Update all rows with a condition using the row
|
add, add, add, add, add, add, add, add, createBottomToolbars, createDataTable, createDataTable, createDataTable, createDataTable, createKeyColumn, createTopToolbars, getColumns, getCssSelected, getDomainClass, getExportableColumns, getFirstTableRow, getHighlighting, getSortKey, getSortKeys, isDefaultColumnSorting, isSortingEnabled, model, setCssClass, setDefaultColumnSorting, setHighlighting, setHighlighting, setSelected, setSelected, setSortpublic ListDataProvider(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> criterion)
criterion - Condition to a database query@NotNull protected @NotNull List<U> getFileredRows()
public Iterator<U> iterator(long first, long count)
iterator in interface org.apache.wicket.markup.repeater.data.IDataProvider<U extends org.ujorm.Ujo>iterator in class AbstractDataProvider<U extends org.ujorm.Ujo>public long size()
size in interface org.apache.wicket.markup.repeater.data.IDataProvider<U extends org.ujorm.Ujo>size in class AbstractDataProvider<U extends org.ujorm.Ujo>public void detach()
detach in interface org.apache.wicket.model.IDetachabledetach in class AbstractDataProvider<U extends org.ujorm.Ujo>protected void clearBuffer()
public boolean insertRow(@NotNull
U row)
insertRow in class AbstractDataProvider<U extends org.ujorm.Ujo>row - Insert the one table rowpublic long deleteRow(@NotNull
@NotNull org.ujorm.criterion.Criterion<? super U> deleteCondition)
deleteRow in class AbstractDataProvider<U extends org.ujorm.Ujo>deleteCondition - Remove all row with a condition.public long updateRow(@NotNull
@NotNull org.ujorm.criterion.Criterion<? super U> updateCondition,
@NotNull
U updatedRow)
updateRow in class AbstractDataProvider<U extends org.ujorm.Ujo>updateCondition - Update conditionupdatedRow - Updated rowpublic static <T extends org.ujorm.Ujo> ListDataProvider<T> of(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<T>> criterion, org.ujorm.Key<? super T,?> defaultSort)
public static <T extends org.ujorm.Ujo> ListDataProvider<T> of(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<T>> criterion)
public static <T extends org.ujorm.Ujo> ListDataProvider<T> of(org.ujorm.criterion.Criterion<T> criterion, org.ujorm.Key<? super T,?> defaultSort)
public static <T extends org.ujorm.Ujo> ListDataProvider<T> of(org.ujorm.criterion.Criterion<? super T> criterion)
Copyright © 2024. All rights reserved.