Class WTable
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WBeanComponent
-
- com.github.bordertech.wcomponents.WTable
-
- All Implemented Interfaces:
AjaxInternalTrigger,AjaxTarget,BeanAware,BeanBound,BeanProviderBound,Container,DataBound,Marginable,NamingContextable,SubordinateTarget,WComponent,WebComponent,Serializable
public class WTable extends WBeanComponent implements Container, AjaxInternalTrigger, AjaxTarget, SubordinateTarget, Marginable, NamingContextable
The WTable component is used to display tabular data. It supports common functions such as sorting and pagination of data.
The WTable component is only concerned with how the UI functions, not the data behind the table. In a MVC sense, the WTable is the Controller, the view is comprised of the WTable layout and column renderers, and the
WTable.TableModelis the model.Columns may only be added statically to the table, but individual columns can be shown/hidden per user by toggling their visibility. See
getColumn(int)andWComponent.setVisible(boolean). Making columns not visible can be problematic with sorting.Another way to make columns not visible is by using
setColumnOrder(int[]). This can be used to change the column order but also hide columns by not including their index in the array.For data that is not in a tree like structure (ie not expandable), the
AdapterBasicTableModel.BasicTableModelinterface can be used via theAdapterBasicTableModel.- Since:
- 1.0.0
- Author:
- Jonathan Austin, Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWTable.ActionConstraintDescribes a constraint on a table action.static interfaceWTable.BeanBoundTableModelThe BeanBoundTableModel provides a link between a bean (bound to a table), and the table model API.static classWTable.ExpandModeThis is used to control how row expansion should work.static classWTable.PaginationLocationThis is used to control where in the table the pagination controls appear.static classWTable.PaginationModeThis is used to control how pagination should work.static classWTable.RowIdWrapperUsed to wrap the row index and the row key (used to uniquely identify the row).static interfaceWTable.ScrollableTableModelThis extension ofWTable.TableModelis primarily for models that do not store their data locally.static classWTable.SelectAllTypeThis is used to control how the "select all" function should work.static classWTable.SelectModeThis is used to control how row selection should work.static classWTable.SeparatorTypeThis is used to control the type of striping used, if any.static classWTable.SortModeThis is used to control how sorting should work.static classWTable.StripingTypeThis is used to control the type of striping used, if any.static interfaceWTable.TableModelTableModel provides the data for tables.static classWTable.TableRepeaterThis repeater extension is necessary to ensure that tree-tables are painted correctly.static classWTable.TypeThis is used to control how table data should be displayed.static classWTable.WTableComponentModelContains the table's UI state.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static StringROW_ID_CONTEXT_PREFIXPrefix used in row ids.static StringSELECTION_ACTION_COMMANDSelection action command.-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WTable()Creates a WTable.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAction(WButton button)Adds a component to the set of table actions.voidaddActionConstraint(WButton button, WTable.ActionConstraint constraint)Adds a constraint to when the given action can be used.voidaddColumn(WTableColumn column)Adds a column to the table.protected voidaddPrevExpandedRow(Object rowKey)Track the row keys that have been expanded.protected voidaddPrevRenderedRow(Object rowKey)Track the row keys that have been rendered.protected voidclearPrevExpandedRows()Clear the previously expanded row keys.protected voidclearPrevRenderedRows()Clear the previously rendered row keys.List<WTable.ActionConstraint>getActionConstraints(WButton button)Retrieves the constraints for the given action.List<WButton>getActions()Retrieves the actions for the table.StringgetCaption()WComponentgetChildAt(int index)Retrieves a child component by its index.intgetChildCount()List<WComponent>getChildren()Retrieves a list of this Container's.WTableColumngetColumn(int index)Retrieves the column at the specified index.intgetColumnCount()Returns the number of columns contained in this table.int[]getColumnOrder()protected WTable.WTableComponentModelgetComponentModel()Returns the effective component model for this component.intgetCurrentPage()Set<?>getExpandedRows()Retrieve the row keys that are expanded.WTable.ExpandModegetExpandMode()intgetIndexOfChild(WComponent childComponent)Retrieves the index of the given child.MargingetMargin()Get the margin for the component, or null if not set.StringgetNamingContextId()Allow components that implementNamingContextableto selectively disable prepending their ID to their descendent's IDs by breaking the prepending logic into a seperately callable method.StringgetNoDataMessage()protected WTable.WTableComponentModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.WTable.PaginationLocationgetPaginationLocation()WTable.PaginationModegetPaginationMode()protected Set<?>getPrevExpandedRows()Return the row keys that have been expanded.protected Set<?>getPrevRenderedRows()Return the row keys that have been rendered.WTable.TableRepeatergetRepeater()protected StringgetRowIdName(List<Integer> rowIndex, Object rowKey)Allows a subclass to provide the ID used in the row naming context.intgetRowsPerPage()The number of rows to display per page.List<Integer>getRowsPerPageOptions()WTable.SelectAllTypegetSelectAllMode()Indicates how the table row "select all" function should be displayed.Set<?>getSelectedRows()Retrieve the row keys that are selected.ActiongetSelectionChangeAction()WTable.SelectModegetSelectMode()WTable.SeparatorTypegetSeparatorType()intgetSortColumnIndex()WTable.SortModegetSortMode()WTable.StripingTypegetStripingType()StringgetSummary()Deprecated.the summary field has been removed from the client side.WTable.TableModelgetTableModel()WTable.TypegetType()voidhandleDataChanged()Method to call when the model data has changed.voidhandleRequest(Request request)Override handleRequest to add table-specific functionality such as pagination and row selection.booleanisEditable()For tables that are editable, extra details about each row must be stored to allow them to be updated.booleanisExpandAll()Indicates whether the "expand all" control should be available.booleanisNamingContext()A naming context is only considered active if an Id name has been set.booleanisPaginated()protected booleanisPresent(Request request)Indicates whether this table was present in the request.booleanisRenderColumnFooters()Control if column footers should be rendered.booleanisRowHeaders()booleanisShowColumnHeaders()Indicates whether table column headers should be displayed.booleanisSortable()Indicates whether the table supports sorting.booleanisSortAscending()Indicates whether the sort on this table is ascending.booleanisSorted()booleanisToggleSubRowSelection()Indicates whether de/selecting a row with sub row(s) will de/select the sub row(s).protected WTable.WTableComponentModelnewComponentModel()Creates a new component model.voidsetCaption(String caption)Sets the table caption text.voidsetColumnOrder(int[] columnOrder)Provide an array of column indexes in the order they should be rendered.voidsetCurrentPage(int currentPage)voidsetEditable(boolean editable)Sets the table to be editable.voidsetExpandAll(boolean expandAll)Sets whether the "expand all" control should be available.voidsetExpandedRows(Set<?> rowKeys)Set the row keys that are expanded.voidsetExpandMode(WTable.ExpandMode expandMode)Sets the row expansion mode.voidsetMargin(Margin margin)Set the margin for the component, or null for no margin.voidsetNamingContext(boolean context)A naming context is only considered active if it has been set active viasetNamingContext(boolean)and also has an id name set viaAbstractWComponent.setIdName(String).voidsetNoDataMessage(String noDataMessage)Sets the message to display when the table contains no rows.voidsetPaginationLocation(WTable.PaginationLocation location)Sets the location in the table to show the pagination controls.voidsetPaginationMode(WTable.PaginationMode paginationMode)Sets the pagination mode.voidsetRenderColumnFooters(boolean renderColumnFooters)voidsetRowHeaders(boolean rowHeaders)Set the table as having row headers.voidsetRowsPerPage(int rowsPerPage)Sets the number of rows to display per page when pagination is enabled.voidsetRowsPerPageOptions(List<Integer> rowsPerPageOptions)Set the rows per page options.voidsetSelectAllMode(WTable.SelectAllType selectAllMode)Sets how the table row "select all" function should be displayed.voidsetSelectedRows(Set<?> rowKeys)Set the row keys that are selected.voidsetSelectionChangeAction(Action selectionChangeAction)Sets the action to execute when row selection changes.voidsetSelectMode(WTable.SelectMode selectMode)Sets the row selection mode.voidsetSeparatorType(WTable.SeparatorType separatorType)Sets the separator used to visually separate rows or columns.voidsetShowColumnHeaders(boolean showColumnHeaders)Sets whether table column headers should be displayed.protected voidsetSort(int index, boolean ascending)For rendering purposes only - has no effect on model.voidsetSortMode(WTable.SortMode sortMode)Sets the table sort mode.voidsetStripingType(WTable.StripingType stripingType)Sets the striping type used to highlight alternate rows or columns.voidsetSummary(String summary)Deprecated.the summary field has been removed from the client side.voidsetTableModel(WTable.TableModel tableModel)Sets the table model which provides the row/column data.voidsetToggleSubRowSelection(boolean toggleSubRowSelection)Sets whether the de/selection of a row with sub rows should de/select the sub rows.voidsetType(WTable.Type type)Sets the table type that controls how the table is displayed.voidsort(int sortCol, boolean sortAsc)Sort the table data by the specified column.StringtoString()Creates a String representation of this component; usually for debugging purposes.voidupdateBeanValue()Updates the bean using the table data model'sWTable.TableModel.setValueAt(Object, List, int)method.-
Methods inherited from class com.github.bordertech.wcomponents.WBeanComponent
addBeanToScratchMap, doUpdateBeanValue, getBean, getBeanFromScratchMap, getBeanId, getBeanProperty, getBeanProvider, getBeanScratchMap, getBeanValue, getData, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, removeBeanFromScratchMap, resetData, setBean, setBeanId, setBeanProperty, setBeanProvider, setData, setSearchAncestors
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Field Detail
-
ROW_ID_CONTEXT_PREFIX
public static final String ROW_ID_CONTEXT_PREFIX
Prefix used in row ids.- See Also:
- Constant Field Values
-
SELECTION_ACTION_COMMAND
public static final String SELECTION_ACTION_COMMAND
Selection action command.- See Also:
- Constant Field Values
-
-
Method Detail
-
setRenderColumnFooters
public void setRenderColumnFooters(boolean renderColumnFooters)
- Parameters:
renderColumnFooters- true if render column footers
-
isRenderColumnFooters
public boolean isRenderColumnFooters()
Control if column footers should be rendered.When true, column footers are rendered on each page. Projects who need to control which page the footers are rendered on (e.g last page) can override this method.
- Returns:
- true if render column footers
-
addColumn
public void addColumn(WTableColumn column)
Adds a column to the table.- Parameters:
column- the column to add.
-
getColumn
public WTableColumn getColumn(int index)
Retrieves the column at the specified index. Bounds checking is not performed, seegetColumnCount().- Parameters:
index- the column index. Zero based.- Returns:
- the column at the specified index.
-
getColumnCount
public int getColumnCount()
Returns the number of columns contained in this table. Invisible columns still count towards the total.- Returns:
- the number of columns contained in this table.
-
getRepeater
public WTable.TableRepeater getRepeater()
- Returns:
- the repeater used to render table rows.
-
getTableModel
public WTable.TableModel getTableModel()
- Returns:
- the table model
-
setTableModel
public void setTableModel(WTable.TableModel tableModel)
Sets the table model which provides the row/column data.- Parameters:
tableModel- the table model.
-
updateBeanValue
public void updateBeanValue()
Updates the bean using the table data model'sWTable.TableModel.setValueAt(Object, List, int)method.The update is only applied if the table has been set as editable via
setEditable(boolean). Only rows that have been rendered are updated.For
WTable.ScrollableTableModel, only the rows on the current page are updated.- Overrides:
updateBeanValuein classWBeanComponent
-
getSeparatorType
public WTable.SeparatorType getSeparatorType()
- Returns:
- the separator type used to visually separate rows or columns.
-
setSeparatorType
public void setSeparatorType(WTable.SeparatorType separatorType)
Sets the separator used to visually separate rows or columns.- Parameters:
separatorType- the separator type to set.
-
setToggleSubRowSelection
public void setToggleSubRowSelection(boolean toggleSubRowSelection)
Sets whether the de/selection of a row with sub rows should de/select the sub rows. This is a client-side only feature.- Parameters:
toggleSubRowSelection- true to turn on this feature.
-
isToggleSubRowSelection
public boolean isToggleSubRowSelection()
Indicates whether de/selecting a row with sub row(s) will de/select the sub row(s).- Returns:
- true if this feature is enabled.
-
getStripingType
public WTable.StripingType getStripingType()
- Returns:
- the striping type used to highlight alternate rows or columns
-
setStripingType
public void setStripingType(WTable.StripingType stripingType)
Sets the striping type used to highlight alternate rows or columns.- Parameters:
stripingType- the striping type to set.
-
isShowColumnHeaders
public boolean isShowColumnHeaders()
Indicates whether table column headers should be displayed.- Returns:
- true if column headers should be displayed, false otherwise.
-
setShowColumnHeaders
public void setShowColumnHeaders(boolean showColumnHeaders)
Sets whether table column headers should be displayed.- Parameters:
showColumnHeaders- true to display table column headers, false otherwise.
-
getSelectionChangeAction
public Action getSelectionChangeAction()
- Returns:
- the action to execute when row selection changes.
-
setSelectionChangeAction
public void setSelectionChangeAction(Action selectionChangeAction)
Sets the action to execute when row selection changes.- Parameters:
selectionChangeAction- the action to execute on row selection change.
-
getNoDataMessage
public String getNoDataMessage()
- Returns:
- the message to display when the table contains no rows.
-
setNoDataMessage
public void setNoDataMessage(String noDataMessage)
Sets the message to display when the table contains no rows.- Parameters:
noDataMessage- the no data message.
-
getSummary
@Deprecated public String getSummary()
Deprecated.the summary field has been removed from the client side. API preserved temporarily for backwards compatibility.- Returns:
- the table summary text.
-
setSummary
@Deprecated public void setSummary(String summary)
Deprecated.the summary field has been removed from the client side. API preserved temporarily for backwards compatibility.Sets the table summary text.- Parameters:
summary- the table summary text to set.
-
getCaption
public String getCaption()
- Returns:
- the table caption text.
-
setCaption
public void setCaption(String caption)
Sets the table caption text.- Parameters:
caption- the table caption text to set.
-
getColumnOrder
public int[] getColumnOrder()
- Returns:
- the column order, or null if the default ordering is to be used.
-
setColumnOrder
public void setColumnOrder(int[] columnOrder)
Provide an array of column indexes in the order they should be rendered. At least one column must be specifed.This can also be used to "hide" columns by not including them in the array.
- Parameters:
columnOrder- the column order to set, or null to use default ordering.
-
setMargin
public void setMargin(Margin margin)
Set the margin for the component, or null for no margin.- Specified by:
setMarginin interfaceMarginable- Parameters:
margin- the margin for the component
-
getMargin
public Margin getMargin()
Get the margin for the component, or null if not set.- Specified by:
getMarginin interfaceMarginable- Returns:
- the margin for the component, or null if not set
-
getPaginationMode
public WTable.PaginationMode getPaginationMode()
- Returns:
- the pagination mode.
-
setPaginationMode
public void setPaginationMode(WTable.PaginationMode paginationMode)
Sets the pagination mode.- Parameters:
paginationMode- the paginationMode to set.
-
getRowsPerPage
public int getRowsPerPage()
The number of rows to display per page. A value of zero, which is only valid when used withsetRowsPerPageOptions(java.util.List), indicates display all rows.- Returns:
- the number of rows to display per page.
-
setRowsPerPage
public void setRowsPerPage(int rowsPerPage)
Sets the number of rows to display per page when pagination is enabled.If rows per page options have been set, then the value must be a valid option, which can include zero to indicate show all rows, otherwise the value must be greater than zero.
- Parameters:
rowsPerPage- the rowsPerPage to set
-
getRowsPerPageOptions
public List<Integer> getRowsPerPageOptions()
- Returns:
- the rows per page options, otherwise null
-
setRowsPerPageOptions
public void setRowsPerPageOptions(List<Integer> rowsPerPageOptions)
Set the rows per page options.If the current value of
getRowsPerPage()is not a valid option, it will be set to the first option.- Parameters:
rowsPerPageOptions- the rows per page options
-
isPaginated
public boolean isPaginated()
- Returns:
- true if table is currently displaying paginated rows
-
getPaginationLocation
public WTable.PaginationLocation getPaginationLocation()
- Returns:
- the location for the pagination controls
-
setPaginationLocation
public void setPaginationLocation(WTable.PaginationLocation location)
Sets the location in the table to show the pagination controls.- Parameters:
location- the PaginationLocation to set.
-
getSelectMode
public WTable.SelectMode getSelectMode()
- Returns:
- the row selection mode.
-
setSelectMode
public void setSelectMode(WTable.SelectMode selectMode)
Sets the row selection mode.- Parameters:
selectMode- the row selection mode to set.
-
getSortMode
public WTable.SortMode getSortMode()
- Returns:
- the sort mode.
-
setSortMode
public void setSortMode(WTable.SortMode sortMode)
Sets the table sort mode. The data model controls which columns are sortable.- Parameters:
sortMode- The sort mode to set.
-
isEditable
public boolean isEditable()
For tables that are editable, extra details about each row must be stored to allow them to be updated. Therefore, if the table is not editable, the table is able to have improved performance.
- Returns:
- true if table is editable
-
setEditable
public void setEditable(boolean editable)
Sets the table to be editable.For tables that are editable, extra details about each row must be stored to allow them to be updated. Therefore, if the table is not editable, the table is able to have improved performance.
- Parameters:
editable- true if editable
-
getType
public WTable.Type getType()
- Returns:
- the table type that controls how the table is displayed.
-
setType
public void setType(WTable.Type type)
Sets the table type that controls how the table is displayed.- Parameters:
type- the table type to set.
-
getSelectAllMode
public WTable.SelectAllType getSelectAllMode()
Indicates how the table row "select all" function should be displayed.- Returns:
- the select all mode.
-
setSelectAllMode
public void setSelectAllMode(WTable.SelectAllType selectAllMode)
Sets how the table row "select all" function should be displayed.- Parameters:
selectAllMode- the select all mode to set.
-
getExpandMode
public WTable.ExpandMode getExpandMode()
- Returns:
- the row expansion mode.
-
setExpandMode
public void setExpandMode(WTable.ExpandMode expandMode)
Sets the row expansion mode.- Parameters:
expandMode- the expand mode to set.
-
isExpandAll
public boolean isExpandAll()
Indicates whether the "expand all" control should be available.- Returns:
- true if the expand all control should be available, false if not.
-
setRowHeaders
public void setRowHeaders(boolean rowHeaders)
Set the table as having row headers.- Parameters:
rowHeaders- indicates that the first data column in the table should be considered a row header.
-
isRowHeaders
public boolean isRowHeaders()
- Returns:
- is the first data column a row header column?
-
setExpandAll
public void setExpandAll(boolean expandAll)
Sets whether the "expand all" control should be available.- Parameters:
expandAll- true if the expand-all control should be available, false if not.
-
getCurrentPage
public int getCurrentPage()
- Returns:
- the current page. Zero based.
-
setCurrentPage
public void setCurrentPage(int currentPage)
- Parameters:
currentPage- the currentPage to set. Zero based.
-
setExpandedRows
public void setExpandedRows(Set<?> rowKeys)
Set the row keys that are expanded.A row key uniquely identifies each row and is determined by the
WTable.TableModel. Refer toWTable.TableModel.getRowKey(List).- Parameters:
rowKeys- the keys of expanded rows.
-
getExpandedRows
public Set<?> getExpandedRows()
Retrieve the row keys that are expanded.A row key uniquely identifies each row and is determined by the
WTable.TableModel. Refer toWTable.TableModel.getRowKey(List).- Returns:
- the expanded row keys.
-
setSelectedRows
public void setSelectedRows(Set<?> rowKeys)
Set the row keys that are selected.A row key uniquely identifies each row and is determined by the
WTable.TableModel. Refer toWTable.TableModel.getRowKey(List).- Parameters:
rowKeys- the keys of selected rows.
-
getSelectedRows
public Set<?> getSelectedRows()
Retrieve the row keys that are selected.A row key uniquely identifies each row and is determined by the
WTable.TableModel. Refer toWTable.TableModel.getRowKey(List).- Returns:
- the selected row keys.
-
getPrevExpandedRows
protected Set<?> getPrevExpandedRows()
Return the row keys that have been expanded.Note - Only used for when the table is editable.
- Returns:
- the previously expanded row keys.
-
addPrevExpandedRow
protected void addPrevExpandedRow(Object rowKey)
Track the row keys that have been expanded.Note - Only used for when the table is editable.
- Parameters:
rowKey- the row key that has been expanded.
-
clearPrevExpandedRows
protected void clearPrevExpandedRows()
Clear the previously expanded row keys.Note - Only used for when the table is editable.
-
getPrevRenderedRows
protected Set<?> getPrevRenderedRows()
Return the row keys that have been rendered.Note - Only used for when the table is editable.
- Returns:
- the previously rendered row keys.
-
addPrevRenderedRow
protected void addPrevRenderedRow(Object rowKey)
Track the row keys that have been rendered.Note - Only used for when the table is editable.
- Parameters:
rowKey- the row key that has been rendered.
-
clearPrevRenderedRows
protected void clearPrevRenderedRows()
Clear the previously rendered row keys.Note - Only used for when the table is editable.
-
setSort
protected void setSort(int index, boolean ascending)For rendering purposes only - has no effect on model.- Parameters:
index- the sort column index, or -1 for no sort.ascending- true for ascending order, false for descending
-
isSorted
public boolean isSorted()
- Returns:
- true if the table is currently sorted
-
getSortColumnIndex
public int getSortColumnIndex()
- Returns:
- the index of the column the table is sorted by.
-
isSortAscending
public boolean isSortAscending()
Indicates whether the sort on this table is ascending. Note that a return value of false does not necessarily indicate a descending sort - seeisSorted().- Returns:
- true if the sort order is ascending, false for descending.
-
isSortable
public boolean isSortable()
Indicates whether the table supports sorting.- Returns:
- true if the table and model both support sorting, false otherwise.
-
getActions
public List<WButton> getActions()
Retrieves the actions for the table.- Returns:
- the list of table actions
-
addAction
public void addAction(WButton button)
Adds a component to the set of table actions.- Parameters:
button- the button to add.
-
addActionConstraint
public void addActionConstraint(WButton button, WTable.ActionConstraint constraint)
Adds a constraint to when the given action can be used.- Parameters:
button- the button which the constraint applies to.constraint- the constraint to add.
-
getActionConstraints
public List<WTable.ActionConstraint> getActionConstraints(WButton button)
Retrieves the constraints for the given action.- Parameters:
button- the button to retrieve the constraints for.- Returns:
- the constraints for the given action, or null if there are no constraints.
-
handleRequest
public void handleRequest(Request request)
Override handleRequest to add table-specific functionality such as pagination and row selection.- Specified by:
handleRequestin interfaceWComponent- Overrides:
handleRequestin classAbstractWComponent- Parameters:
request- the request being responded to.
-
isPresent
protected boolean isPresent(Request request)
Indicates whether this table was present in the request.- Parameters:
request- the request being responded to.- Returns:
- true if this table was present in the request, false if not.
-
sort
public void sort(int sortCol, boolean sortAsc)Sort the table data by the specified column.- Parameters:
sortCol- the column to sortsortAsc- true if sort ascending, otherwise sort descending
-
handleDataChanged
public void handleDataChanged()
Method to call when the model data has changed. For example, when a row has been added or removed.Handles resorting the data (if table sorted) and making sure the table pagination is still correct.
-
getRowIdName
protected String getRowIdName(List<Integer> rowIndex, Object rowKey)
Allows a subclass to provide the ID used in the row naming context. It is important this ID is unique for each row.The returned ID must only contain letters, digits or underscores.
- Parameters:
rowIndex- the current row indexrowKey- the current row key.- Returns:
- the unique row id or null to use the default context id
-
getChildCount
public int getChildCount()
- Specified by:
getChildCountin interfaceContainer- Returns:
- the number of child components currently contained within this component.
-
getChildAt
public WComponent getChildAt(int index)
Retrieves a child component by its index.- Specified by:
getChildAtin interfaceContainer- Parameters:
index- the index of the child component to be retrieved.- Returns:
- the child component at the given index.
-
getIndexOfChild
public int getIndexOfChild(WComponent childComponent)
Retrieves the index of the given child.- Specified by:
getIndexOfChildin interfaceContainer- Parameters:
childComponent- the child component to retrieve the index for.- Returns:
- the index of the given child component, or -1 if the component is not a child of this component.
-
getChildren
public List<WComponent> getChildren()
Retrieves a list of this Container's.- Specified by:
getChildrenin interfaceContainer- Returns:
- an immutable list of this Container.
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component, for debugging purposes.
-
setNamingContext
public void setNamingContext(boolean context)
A naming context is only considered active if it has been set active viasetNamingContext(boolean)and also has an id name set viaAbstractWComponent.setIdName(String).- Parameters:
context- set true if this is a naming context.
-
isNamingContext
public boolean isNamingContext()
A naming context is only considered active if an Id name has been set.- Specified by:
isNamingContextin interfaceNamingContextable- Returns:
- true if active naming context.
-
getNamingContextId
public String getNamingContextId()
Allow components that implementNamingContextableto selectively disable prepending their ID to their descendent's IDs by breaking the prepending logic into a seperately callable method.See
WComponent.getId()for usage.By default, this method will call through to
WComponent.getId()and return the result.- Specified by:
getNamingContextIdin interfaceNamingContextable- Returns:
- by default, return getId().
-
newComponentModel
protected WTable.WTableComponentModel newComponentModel()
Creates a new component model.- Overrides:
newComponentModelin classWBeanComponent- Returns:
- a new TableModel.
-
getComponentModel
protected WTable.WTableComponentModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModelin classWBeanComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WTable.WTableComponentModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModelin classWBeanComponent- Returns:
- the model for this component
-
-