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
,IHierarchical<Component>
,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
-
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBottomToolbar
(AbstractToolbar toolbar) Adds a toolbar to the datatable that will be displayed after the datavoid
addTopToolbar
(AbstractToolbar toolbar) Adds a toolbar to the datatable that will be displayed before the datafinal WebMarkupContainer
getBody()
final WebMarkupContainer
final DataTable.Caption
Returns the model for table's caption.final ColGroup
final long
final IDataProvider<T>
long
Gets the total number of items this object has.final long
maximum number of visible items per pagefinal long
Gets the total number of pages this pageable object has.final long
final WebMarkupContainer
protected WebMarkupContainer
Create 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 void
Processes the component tag.protected void
onDetach()
Called to allow a component to detach resources after use.protected void
Event listener for page-changed eventfinal void
setCurrentPage
(long page) Sets the a page that should be rendered (page number is zero-based)setItemReuseStrategy
(IItemReuseStrategy strategy) Sets the item reuse strategy.void
setItemsPerPage
(long items) Sets the number of items to be displayed per pagefinal void
setTableBodyCss
(String cssStyle) Set the 'class' attribute for the tbody tag.Methods inherited from class org.apache.wicket.markup.html.panel.Panel
getRegionMarkup, newMarkupSourcingStrategy
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
Methods 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, visitChildren
Methods 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, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, newDequeueContext
Methods 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:
getCurrentPage
in interfaceIPageable
- Returns:
- The current page that is or will be rendered (page number is zero-based)
- See Also:
getPageCount
Description copied from interface:IPageable
Gets the total number of pages this pageable object has.- Specified by:
getPageCount
in interfaceIPageable
- Returns:
- The total number of pages this pageable object has
- See Also:
getRowCount
- Returns:
- total number of rows in this table
getItemsPerPage
Description copied from interface:IPageableItems
maximum number of visible items per page- Specified by:
getItemsPerPage
in interfaceIPageableItems
- Returns:
- number of rows per page
setCurrentPage
Description copied from interface:IPageable
Sets the a page that should be rendered (page number is zero-based)- Specified by:
setCurrentPage
in interfaceIPageable
- Parameters:
page
- The page that should be rendered.- See Also:
setItemReuseStrategy
Sets the item reuse strategy. This strategy controls the creation ofItem
s.- Parameters:
strategy
- item reuse strategy- Returns:
- this for chaining
- See Also:
setItemsPerPage
Sets the number of items to be displayed per page- Specified by:
setItemsPerPage
in interfaceIPageableItems
- Parameters:
items
- number of items to display per page
getItemCount
Description copied from interface:IPageableItems
Gets the total number of items this object has.- Specified by:
getItemCount
in interfaceIPageableItems
- Returns:
- The total number of items this object has.
- 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
Description copied from class:Component
Called to allow a component to detach resources after use. Overrides of this method MUST call the super implementation, the most logical place to do this is the last line of the override method.- Overrides:
onDetach
in classMarkupContainer
- See Also:
onPageChanged
Event listener for page-changed eventonComponentTag
Description copied from class:Component
Processes the component tag. Overrides of this method most likely should call the super implementation.- Overrides:
onComponentTag
in classComponent
- Parameters:
tag
- Tag to modify
-