Module org.apache.wicket.extensions
Class DataTable<T,S>
java.lang.Object
org.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.html.panel.Panel
org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<T,S>
- Type Parameters:
T- The model object typeS- the type of the sorting parameter
- All Implemented Interfaces:
Serializable,Iterable<Component>,IEventSink,IEventSource,IFeedbackContributor,IConverterLocator,IMetadataContext<Serializable,,Component> IQueueRegion,IHeaderContributor,IPageable,IPageableItems,IRequestableComponent,org.apache.wicket.util.IHierarchical<Component>,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
AjaxFallbackDefaultDataTable,DefaultDataTable
A data table builds on data grid view to introduce toolbars. Toolbars can be used to display
sortable column headers, paging information, filter controls, and other information.
Data table also provides its own markup for an html table so the developer 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 )
// Application specific POJO to view/edit
public class MyEntity {
private String firstName;
private String lastName;
// getters and setters
}
public class MyEntityProvider implements IDataProvider<MyEntity> {
...
}
List<IColumn<MyEntity, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<MyEntity, String>(new Model<String>("First Name"), "firstName", "firstName"));
columns.add(new PropertyColumn<MyEntity, String>(new Model<String>("Last Name"), "lastName"));
DataTable<MyEntity,String> table = new DataTable<>("datatable", columns, new MyEntityProvider(), 10);
table.addBottomToolbar(new NavigationToolbar(table));
table.addTopToolbar(new HeadersToolbar(table, null));
add(table);
- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBottomToolbar(AbstractToolbar toolbar) Adds a toolbar to the datatable that will be displayed after the datavoidaddTopToolbar(AbstractToolbar toolbar) Adds a toolbar to the datatable that will be displayed before the datafinal WebMarkupContainergetBody()final WebMarkupContainerfinal DataTable.CaptionReturns the model for table's caption.final ColGroupfinal longfinal IDataProvider<T>longfinal longfinal longfinal longfinal WebMarkupContainerprotected WebMarkupContainerCreate the MarkupContainer for the tag.Factory method for Item container that represents a cell in the underlying DataGridViewprotected DataGridView<T>newDataGridView(String id, List<? extends IColumn<T, S>> columns, IDataProvider<T> dataProvider) Factory method for the DataGridViewnewRowItem(String id, int index, IModel<T> model) Factory method for Item container that represents a row in the underlying DataGridViewprotected voidprotected voidonDetach()protected voidEvent listener for page-changed eventfinal voidsetCurrentPage(long page) setItemReuseStrategy(IItemReuseStrategy strategy) Sets the item reuse strategy.voidsetItemsPerPage(long items) Sets the number of items to be displayed per pagefinal voidsetTableBodyCss(String cssStyle) Set the 'class' attribute for the tbody tag.Methods inherited from class org.apache.wicket.markup.html.panel.Panel
getRegionMarkup, newMarkupSourcingStrategyMethods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSessionMethods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildrenMethods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, 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, getMarkupTag, 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, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.wicket.IQueueRegion
dequeue, newDequeueContextMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Method Details
-
newDataGridView
protected DataGridView<T> newDataGridView(String id, List<? extends IColumn<T, S>> columns, IDataProvider<T> dataProvider) Factory method for the DataGridView- Parameters:
id- The component idcolumns- list of IColumn objectsdataProvider- imodel for data provider- Returns:
- the data grid view
-
getCaptionModel
Returns the model for table's caption. The caption wont be rendered if the model has empty value.- Returns:
- the model for table's caption
-
getColGroup
-
newBodyContainer
Create the MarkupContainer for the tag. Developers may subclass it to provide their own (modified) implementation.- Parameters:
id-- Returns:
- A new markup container
setTableBodyCss
Set the 'class' attribute for the tbody tag.- Parameters:
cssStyle-
addBottomToolbar
Adds a toolbar to the datatable that will be displayed after the data- Parameters:
toolbar- toolbar to be added- See Also:
addTopToolbar
Adds a toolbar to the datatable that will be displayed before the data- Parameters:
toolbar- toolbar to be added- See Also:
getTopToolbars
- Returns:
- the container with the toolbars at the top
getBottomToolbars
- Returns:
- the container with the toolbars at the bottom
getBody
- Returns:
- the container used for the table body
getCaption
- Returns:
- the component used for the table caption
getDataProvider
- Returns:
- dataprovider
getColumns
- Returns:
- array of column objects this table displays
getCurrentPage
- Specified by:
getCurrentPagein interfaceIPageable- See Also:
getPageCount
- Specified by:
getPageCountin interfaceIPageable- See Also:
getRowCount
- Returns:
- total number of rows in this table
getItemsPerPage
- Specified by:
getItemsPerPagein interfaceIPageableItems- Returns:
- number of rows per page
setCurrentPage
- Specified by:
setCurrentPagein interfaceIPageable- See Also:
setItemReuseStrategy
Sets the item reuse strategy. This strategy controls the creation ofItems.- Parameters:
strategy- item reuse strategy- Returns:
- this for chaining
- See Also:
setItemsPerPage
Sets the number of items to be displayed per page- Specified by:
setItemsPerPagein interfaceIPageableItems- Parameters:
items- number of items to display per page
getItemCount
- Specified by:
getItemCountin interfaceIPageableItems- See Also:
newCellItem
Factory method for Item container that represents a cell in the underlying DataGridView- Parameters:
id- component id for the new data itemindex- the index of the new data itemmodel- the model for the new data item- Returns:
- DataItem created DataItem
- See Also:
newRowItem
Factory method for Item container that represents a row in the underlying DataGridView- Parameters:
id- component id for the new data itemindex- the index of the new data itemmodel- the model for the new data item.- Returns:
- DataItem created DataItem
- See Also:
onDetach
- Overrides:
onDetachin classMarkupContainer- See Also:
onPageChanged
Event listener for page-changed eventonComponentTag
- Overrides:
onComponentTagin classComponent
-