public abstract class AbstractDataProvider<U extends Ujo> extends org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider<U,Object>
This class called UjoDataProvider is an database
Wicket DataProvider. For a customization you can use a your own IColumn implementations
or you can owerwrite 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 owerwrite 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));
| Modifier and Type | Field and Description |
|---|---|
protected static String |
DEFAULT_CSS_SELECTED
Default CSS style for a SELECTED row
|
static String |
DEFAULT_DATATABLE_ID
Default Datatable ID have got value
"datatable". |
protected org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> |
filter
Data criterion model for filtering the data resource
|
protected org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> |
selected
Data criterion model for select data rows
|
protected Long |
size
Data size
|
| Constructor and Description |
|---|
AbstractDataProvider(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> criterion)
Constructor
|
AbstractDataProvider(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> filter,
Key<? super U,?> defaultSort)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<? super U,?> column)
Add table column
|
<V> boolean |
add(Key<? super U,V> column)
Add table column according to column type
|
<V> boolean |
add(Key<? super U,V> column,
CssAppender cssClass)
Add table column according to column type including CSS class
|
void |
add(KeyList<? super U> columns)
Add table columns according to column type including CSS class
|
<S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> |
createDataTable(int rowsPerPage)
Create AJAX-based DataTable with a
DEFAULT_DATATABLE_ID |
<S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> |
createDataTable(int rowsPerPage,
boolean insertToolbar)
Create AJAX-based DataTable
|
<S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> |
createDataTable(String id,
int rowsPerPage)
Create AJAX-based DataTable
|
<S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> |
createDataTable(String id,
int rowsPerPage,
boolean insertToolbar)
Create AJAX-based DataTable
|
long |
deleteRow(org.ujorm.criterion.Criterion<? super U> deleteCondition)
Delete rows from the data source
The method is not implemented by default.
|
abstract void |
detach()
Commit and close transaction
|
List<org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<U,?>> |
getColumns()
Transient tableOf columns
|
protected String |
getCssSelected()
Returns a CSS style for SELECTED row.
|
Class<U> |
getDomainClass()
Get a domann class
|
org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> |
getSelected()
Data criterion model for select data rows
|
Key<U,?> |
getSortKey()
Vrací klíč pro řazení
|
boolean |
insertRow(U row)
Insert row to the data source.
|
boolean |
isDefaultColumnSorting()
Default column sorting for the method
#addColumn(org.ujorm.Key)
where the feature is enabled by default |
protected boolean |
isSortingEnabled(Key<U,?> column)
The sorting is enabled for a persistent Ujorm Key by default
|
abstract Iterator<U> |
iterator(long first,
long count)
Build a JDBC ResultSet allways.
|
org.apache.wicket.model.IModel<U> |
model(U object)
Create a model
|
void |
setCssClass(Key<? super U,?> key,
String cssClass)
Assign a CSS class to a KeyColumn, if exists
|
void |
setDefaultColumnSorting(boolean defaultColumnSorting)
Default column sorting for the method
#addColumn(org.ujorm.Key)
where the feature is enabled by default |
void |
setSelected(org.ujorm.criterion.Criterion<U> selected)
Data criterion model for select data rows
|
void |
setSelected(org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> selected)
Data criterion model for select data rows
|
void |
setSort(Key<? super U,?> key)
Sets the current sort state and assign the BaseClass
|
abstract long |
size()
Method calculate the size using special SQL requst.
|
long |
updateRow(org.ujorm.criterion.Criterion<? super U> updateCondition,
U updatedRow)
Update all rows with a condition using the row
The method is not implemented by default.
|
public static final String DEFAULT_DATATABLE_ID
"datatable".protected static final String DEFAULT_CSS_SELECTED
protected Long size
protected org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U extends Ujo>> filter
protected org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U extends Ujo>> selected
public AbstractDataProvider(@Nonnull
org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> criterion)
criterion - Condition to a database querypublic AbstractDataProvider(@Nonnull
org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> filter,
@Nullable
Key<? super U,?> defaultSort)
filter - Model of a condition to a database querydefaultSort - Default sorting can be assigned optionallypublic final void setSort(Key<? super U,?> key)
key - sort keyorder - sort orderpublic abstract Iterator<U> iterator(long first, long count)
public abstract long size()
public abstract void detach()
public boolean add(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<? super U,?> column)
public void add(KeyList<? super U> columns)
public <V> boolean add(Key<? super U,V> column, CssAppender cssClass)
protected String getCssSelected()
DEFAULT_CSS_SELECTEDprotected boolean isSortingEnabled(Key<U,?> column) throws IllegalArgumentException
IllegalArgumentExceptionisDefaultColumnSorting()public final <S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> createDataTable(int rowsPerPage)
DEFAULT_DATATABLE_IDpublic final <S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> createDataTable(String id, int rowsPerPage)
public final <S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> createDataTable(int rowsPerPage, boolean insertToolbar)
public <S> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> createDataTable(String id, int rowsPerPage, boolean insertToolbar)
id - Component IDrowsPerPage - Row count per the one pageinsertToolbar - Append a generic toolbar for an insert action.public final boolean isDefaultColumnSorting()
#addColumn(org.ujorm.Key)
where the feature is enabled by defaultpublic void setDefaultColumnSorting(boolean defaultColumnSorting)
#addColumn(org.ujorm.Key)
where the feature is enabled by defaultdefaultColumnSorting - the defaultColumnSorting to setpublic List<org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<U,?>> getColumns()
public void setCssClass(Key<? super U,?> key, String cssClass)
@Nullable public org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> getSelected()
public void setSelected(@Nullable
org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> selected)
selected - the selected to setpublic void setSelected(@Nonnull
org.ujorm.criterion.Criterion<U> selected)
selected - the selected to setpublic boolean insertRow(U row)
row - Insert one table rowpublic long deleteRow(org.ujorm.criterion.Criterion<? super U> deleteCondition)
deleteCondition - Remove all row with a condition.public long updateRow(org.ujorm.criterion.Criterion<? super U> updateCondition, U updatedRow)
updateCondition - Update conditionupdatedRow - Updated rowCopyright © 2014. All Rights Reserved.