wicket.extensions.markup.html.repeater.data.table
Class DataTable

java.lang.Object
  extended by wicket.Component
      extended by wicket.MarkupContainer
          extended by wicket.markup.html.WebMarkupContainer
              extended by wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
                  extended by wicket.markup.html.panel.Panel
                      extended by wicket.extensions.markup.html.repeater.data.table.DataTable
All Implemented Interfaces:
java.io.Serializable, wicket.markup.html.navigation.paging.IPageable
Direct Known Subclasses:
AjaxFallbackDefaultDataTable, DefaultDataTable

public class DataTable
extends wicket.markup.html.panel.Panel
implements wicket.markup.html.navigation.paging.IPageable

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 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 )
 
 IColumn[] columns = new IColumn[2];
 
 columns[0] = new PropertyColumn(new Model("First Name"), "name.first", "name.first");
 columns[1] = new PropertyColumn(new Model("Last Name"), "name.last");
 
 DataTable table = new DataTable("datatable", columns, new UserProvider(), 10);
 table.add(new NavigationToolbar(table));
 table.add(new HeadersToolbar(table));
 add(table);
 
 

Author:
Igor Vaynberg (ivaynberg)
See Also:
DefaultDataTable, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.HeaderPartContainer
 
Nested classes/interfaces inherited from class wicket.Component
wicket.Component.ComponentModelChange, wicket.Component.EnabledChange, wicket.Component.IVisitor, wicket.Component.VisibilityChange
 
Field Summary
static java.lang.String TOOLBAR_COMPONENT_ID
          The component id that toolbars must be created with in order to be added to the data table
 
Fields inherited from class wicket.Component
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Constructor Summary
DataTable(java.lang.String id, IColumn[] columns, IDataProvider dataProvider, int rowsPerPage)
          Constructor
 
Method Summary
 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
 IColumn[] getColumns()
           
 int getCurrentPage()
           
 int getPageCount()
           
 int getRowCount()
           
 int getRowsPerPage()
           
protected  Item newCellItem(java.lang.String id, int index, wicket.model.IModel model)
          Factory method for Item container that represents a cell in the underlying DataGridView
protected  Item newRowItem(java.lang.String id, int index, wicket.model.IModel model)
          Factory method for Item container that represents a row in the underlying DataGridView
protected  void onPageChanged()
          Event listener for page-changed event
 void setCurrentPage(int page)
           
 DataTable setItemReuseStrategy(IItemReuseStrategy strategy)
          Sets the item reuse strategy.
 void setRowsPerPage(int items)
          Sets the number of items to be displayed per page
 
Methods inherited from class wicket.markup.html.panel.Panel
onComponentTag, onComponentTagBody, renderHead
 
Methods inherited from class wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
newHeaderPartContainer, renderHeadFromAssociatedMarkupFile
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, internalAdd, internalAttach, internalDetach, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, addStateChange, checkComponentTag, checkComponentTagAttribute, continueToOriginalDestination, debug, detachBehaviors, detachModel, detachModels, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getApplicationPages, getApplicationSettings, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getOutputMarkupId, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isBehaviorAccepted, isEnableAllowed, isEnabled, isHeadRendered, isIgnoreAttributeModifier, isRenderAllowed, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onDetach, onEndRequest, onModelChanged, onModelChanging, onRender, redirectToInterceptPage, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderedBehaviors, replaceComponentTagBody, replaceWith, resetHeadRendered, sameRootModel, sameRootModel, setAuto, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMetaData, setModelObject, setOutputMarkupId, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOOLBAR_COMPONENT_ID

public static final java.lang.String TOOLBAR_COMPONENT_ID
The component id that toolbars must be created with in order to be added to the data table

See Also:
Constant Field Values
Constructor Detail

DataTable

public DataTable(java.lang.String id,
                 IColumn[] columns,
                 IDataProvider dataProvider,
                 int rowsPerPage)
Constructor

Parameters:
id - component id
columns - list of IColumn objects
dataProvider - imodel for data provider
rowsPerPage - number of rows per page
Method Detail

getColumns

public final IColumn[] getColumns()
Returns:
array of column objects this table displays

addTopToolbar

public void addTopToolbar(AbstractToolbar toolbar)
Adds a toolbar to the datatable that will be displayed before the data

Parameters:
toolbar - toolbar to be added
See Also:
AbstractToolbar

addBottomToolbar

public void addBottomToolbar(AbstractToolbar toolbar)
Adds a toolbar to the datatable that will be displayed after the data

Parameters:
toolbar - toolbar to be added
See Also:
AbstractToolbar

getCurrentPage

public final int getCurrentPage()
Specified by:
getCurrentPage in interface wicket.markup.html.navigation.paging.IPageable
See Also:
IPageable.getCurrentPage()

setCurrentPage

public final void setCurrentPage(int page)
Specified by:
setCurrentPage in interface wicket.markup.html.navigation.paging.IPageable
See Also:
IPageable.setCurrentPage(int)

onPageChanged

protected void onPageChanged()
Event listener for page-changed event


getPageCount

public final int getPageCount()
Specified by:
getPageCount in interface wicket.markup.html.navigation.paging.IPageable
See Also:
IPageable.getPageCount()

getRowCount

public final int getRowCount()
Returns:
total number of rows in this table

setRowsPerPage

public void setRowsPerPage(int items)
Sets the number of items to be displayed per page

Parameters:
items - number of items to display per page

getRowsPerPage

public final int getRowsPerPage()
Returns:
number of rows per page

newRowItem

protected Item newRowItem(java.lang.String id,
                          int index,
                          wicket.model.IModel model)
Factory method for Item container that represents a row in the underlying DataGridView

Parameters:
id - component id for the new data item
index - the index of the new data item
model - the model for the new data item.
Returns:
DataItem created DataItem
See Also:
Item

newCellItem

protected Item newCellItem(java.lang.String id,
                           int index,
                           wicket.model.IModel model)
Factory method for Item container that represents a cell in the underlying DataGridView

Parameters:
id - component id for the new data item
index - the index of the new data item
model - the model for the new data item
Returns:
DataItem created DataItem
See Also:
Item

setItemReuseStrategy

public final DataTable setItemReuseStrategy(IItemReuseStrategy strategy)
Sets the item reuse strategy. This strategy controls the creation of Items.

Parameters:
strategy - item reuse strategy
Returns:
this for chaining
See Also:
RefreshingView.setItemReuseStrategy(IItemReuseStrategy), IItemReuseStrategy


Copyright © 2004-2008 Wicket developers. All Rights Reserved.