T
- The model object typeS
- the type of the sorting parameterpublic class DataTable<T,S> extends Panel implements IPageableItems
Data table also provides its own markup for an html table so the user does not need to provide it himself. This makes it very simple to add a datatable to the markup, however, some flexibility.
Example
<table wicket:id="datatable"></table>And the related Java code: ( the first column will be sortable because its sort property is specified, the second column will not )
List<IColumn<T>> columns = new ArrayList<IColumn<T>>(); columns.add(new PropertyColumn(new Model<String>("First Name"), "name.first", "name.first")); columns.add(new PropertyColumn(new Model<String>("Last Name"), "name.last")); DataTable table = new DataTable("datatable", columns, new UserProvider(), 10); table.addBottomToolbar(new NavigationToolbar(table)); table.addTopToolbar(new HeadersToolbar(table, null)); add(table);
DefaultDataTable
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
DataTable.Caption
A caption for the table.
|
ENABLE, FLAG_AFTER_RENDERING, FLAG_INITIALIZED, FLAG_PREPARED_FOR_RENDER, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RENDERING, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING
Constructor and Description |
---|
DataTable(String id,
List<? extends IColumn<T,S>> columns,
IDataProvider<T> dataProvider,
long rowsPerPage)
Constructor
|
Modifier and Type | Method and Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
void |
addBottomToolbar(AbstractToolbar toolbar)
Adds a toolbar to the datatable that will be displayed after the data
|
||||||||||||||||||||
void |
addTopToolbar(AbstractToolbar toolbar)
Adds a toolbar to the datatable that will be displayed before the data
|
||||||||||||||||||||
WebMarkupContainer |
getBody() |
||||||||||||||||||||
org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable.ToolbarsContainer |
getBottomToolbars() |
||||||||||||||||||||
DataTable.Caption |
getCaption() |
||||||||||||||||||||
protected IModel<String> |
getCaptionModel()
Returns the model for table's caption.
|
||||||||||||||||||||
ColGroup |
getColGroup() |
||||||||||||||||||||
List<? extends IColumn<T,S>> |
getColumns() |
||||||||||||||||||||
long |
getCurrentPage() |
||||||||||||||||||||
IDataProvider<T> |
getDataProvider() |
||||||||||||||||||||
long |
getItemCount()
Gets the total number of items this object has.
|
||||||||||||||||||||
long |
getItemsPerPage()
maximum number of visible items per page
|
||||||||||||||||||||
long |
getPageCount()
Gets the total number of pages this pageable object has.
|
||||||||||||||||||||
long |
getRowCount() |
||||||||||||||||||||
org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable.ToolbarsContainer |
getTopToolbars() |
||||||||||||||||||||
protected WebMarkupContainer |
newBodyContainer(String id)
Create the MarkupContainer for the tag.
protected Item<IColumn<T,S>> newCellItem(String id,
int index,
IModel<IColumn<T,S>> model)
Factory method for Item container that represents a cell in the underlying DataGridView
protected DataGridView<T> newDataGridView(String id,
List<? extends IColumn<T,S>> columns,
IDataProvider<T> dataProvider)
Factory method for the DataGridView
protected Item<T> newRowItem(String id,
int index,
IModel<T> model)
Factory method for Item container that represents a row in the underlying DataGridView
protected void onComponentTag(ComponentTag tag)
Processes the component tag.
protected void onDetach()
Called to allow a component to detach resources after use.
protected void onPageChanged()
Event listener for page-changed event
void setCurrentPage(long page)
Sets the a page that should be rendered (page number is zero-based)
DataTable<T,S> setItemReuseStrategy(IItemReuseStrategy strategy)
Sets the item reuse strategy.
void setItemsPerPage(long items)
Sets the number of items to be displayed per page
void setTableBodyCss(String cssStyle)
Set the 'class' attribute for the tbody tag.
|
getRegionMarkup, newMarkupSourcingStrategy
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dequeue, newDequeueContext
protected DataGridView<T> newDataGridView(String id, List<? extends IColumn<T,S>> columns, IDataProvider<T> dataProvider)
id
- The component idcolumns
- list of IColumn objectsdataProvider
- imodel for data providerprotected IModel<String> getCaptionModel()
public final ColGroup getColGroup()
protected WebMarkupContainer newBodyContainer(String id)
id
- public final void setTableBodyCss(String cssStyle)
cssStyle
- public void addBottomToolbar(AbstractToolbar toolbar)
toolbar
- toolbar to be addedAbstractToolbar
public void addTopToolbar(AbstractToolbar toolbar)
toolbar
- toolbar to be addedAbstractToolbar
public final org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable.ToolbarsContainer getTopToolbars()
public final org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable.ToolbarsContainer getBottomToolbars()
public final WebMarkupContainer getBody()
public final DataTable.Caption getCaption()
public final IDataProvider<T> getDataProvider()
public final List<? extends IColumn<T,S>> getColumns()
public final long getCurrentPage()
getCurrentPage
in interface IPageable
IPageable.getCurrentPage()
public final long getPageCount()
IPageable
getPageCount
in interface IPageable
IPageable.getPageCount()
public final long getRowCount()
public final long getItemsPerPage()
IPageableItems
getItemsPerPage
in interface IPageableItems
public final void setCurrentPage(long page)
IPageable
setCurrentPage
in interface IPageable
page
- The page that should be rendered.IPageable.setCurrentPage(long)
public final DataTable<T,S> setItemReuseStrategy(IItemReuseStrategy strategy)
Item
s.strategy
- item reuse strategyRefreshingView.setItemReuseStrategy(IItemReuseStrategy)
,
IItemReuseStrategy
public void setItemsPerPage(long items)
setItemsPerPage
in interface IPageableItems
items
- number of items to display per pagepublic long getItemCount()
IPageableItems
getItemCount
in interface IPageableItems
IPageableItems.getItemCount()
protected Item<IColumn<T,S>> newCellItem(String id, int index, IModel<IColumn<T,S>> model)
id
- component id for the new data itemindex
- the index of the new data itemmodel
- the model for the new data itemItem
protected Item<T> newRowItem(String id, int index, IModel<T> model)
id
- component id for the new data itemindex
- the index of the new data itemmodel
- the model for the new data item.Item
protected void onDetach()
Component
onDetach
in class MarkupContainer
Component.onDetach()
protected void onPageChanged()
protected void onComponentTag(ComponentTag tag)
Component
onComponentTag
in class Component
tag
- Tag to modifyCopyright © 2006–2021 Apache Software Foundation. All rights reserved.