|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider<U,Object>
org.ujorm.wicket.component.grid.AbstractDataProvider<U>
public abstract class AbstractDataProvider<U extends Ujo>
This class called UjoDataProvider is an common
Wicket DataProvider to create an AJAX DataTable component.
For a column customizations you can use 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));
| Field Summary | |
|---|---|
protected static String |
DEFAULT_CSS_ACTION
Default CSS style for an ACTION COLUMN |
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 Summary | |
|---|---|
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 |
|
| Method Summary | ||
|---|---|---|
boolean |
add(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<? super U,?> column)
Add table column |
|
|
add(Key<? super U,V> column)
Add table column according to column type |
|
|
add(Key<? super U,V> column,
Class<? extends org.apache.wicket.markup.html.WebMarkupContainer> panelClass)
Create new instance of a Panel from the argument panelClass
and add the result to the grid as new column. |
|
|
add(Key<? super U,V> column,
CommonAction... actions)
Create new instance of an Action Panel using actions from the argument list. |
|
|
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 |
|
protected
|
createBottomToolbars(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> result)
Create default bottom table toolbars: NoRecordsToolbar |
|
|
createDataTable(int rowsPerPage)
Create AJAX-based DataTable with a DEFAULT_DATATABLE_ID |
|
|
createDataTable(int rowsPerPage,
boolean insertToolbar)
Create AJAX-based DataTable |
|
|
createDataTable(String id,
int rowsPerPage)
Create AJAX-based DataTable |
|
|
createDataTable(String id,
int rowsPerPage,
boolean insertToolbar)
Create AJAX-based DataTable |
|
protected
|
createTopToolbars(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> result)
Create default top table toolbars: AjaxNavigationToolbar and AjaxFallbackHeadersToolbar |
|
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 |
|
|
getColumns()
Column table list |
|
protected String |
getCssSelected()
Returns a CSS style for SELECTED row. |
|
Class<U> |
getDomainClass()
Get a domain class |
|
org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> |
getSelected()
Data criterion model for select data rows |
|
Key<U,?> |
getSortKey()
Returns a sorting Key |
|
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 always. |
|
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 request. |
|
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. |
|
| Methods inherited from class org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider |
|---|
getSort, getSortState, setSort, setSort |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_DATATABLE_ID
"datatable".
protected static final String DEFAULT_CSS_SELECTED
protected static final String DEFAULT_CSS_ACTION
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
| Constructor Detail |
|---|
public AbstractDataProvider(@Nonnull
org.apache.wicket.model.IModel<org.ujorm.criterion.Criterion<U>> criterion)
criterion - Condition to a database query
public 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 optionally| Method Detail |
|---|
public final void setSort(Key<? super U,?> key)
key - sort keyorder - sort orderpublic Key<U,?> getSortKey()
public abstract Iterator<U> iterator(long first,
long count)
public abstract long size()
public abstract void detach()
detach in interface org.apache.wicket.model.IDetachabledetach in class org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider<U extends Ujo,Object>public Class<U> getDomainClass()
public org.apache.wicket.model.IModel<U> model(U object)
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)
public <V> boolean add(Key<? super U,V> column)
public <V> void add(Key<? super U,V> column,
Class<? extends org.apache.wicket.markup.html.WebMarkupContainer> panelClass)
panelClass
and add the result to the grid as new column.
V - Value typecolumn - Key for the column, where the Key can't get data.panelClass - A panel with two constructor arguments:
Key.getDomainType()
public <V> void add(Key<? super U,V> column,
CommonAction... actions)
V - Value typecolumn - Key for the column, where the Key can't get data.actions - Action arrayprotected String getCssSelected()
DEFAULT_CSS_SELECTED
protected 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_ID
public 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.
protected <S> void createTopToolbars(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> result)
protected <S> void createBottomToolbars(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<U,S> result)
public final boolean isDefaultColumnSorting()
#addColumn(org.ujorm.Key)
where the feature is enabled by default
public void setDefaultColumnSorting(boolean defaultColumnSorting)
#addColumn(org.ujorm.Key)
where the feature is enabled by default
defaultColumnSorting - the defaultColumnSorting to setpublic <T> List<org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<U,T>> 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 set
public 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 row
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||