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.TableModel
is 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.BasicTableModel
interface 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 class
WTable.ActionConstraint
Describes a constraint on a table action.static interface
WTable.BeanBoundTableModel
The BeanBoundTableModel provides a link between a bean (bound to a table), and the table model API.static class
WTable.ExpandMode
This is used to control how row expansion should work.static class
WTable.PaginationLocation
This is used to control where in the table the pagination controls appear.static class
WTable.PaginationMode
This is used to control how pagination should work.static class
WTable.RowIdWrapper
Used to wrap the row index and the row key (used to uniquely identify the row).static interface
WTable.ScrollableTableModel
This extension ofWTable.TableModel
is primarily for models that do not store their data locally.static class
WTable.SelectAllType
This is used to control how the "select all" function should work.static class
WTable.SelectMode
This is used to control how row selection should work.static class
WTable.SeparatorType
This is used to control the type of striping used, if any.static class
WTable.SortMode
This is used to control how sorting should work.static class
WTable.StripingType
This is used to control the type of striping used, if any.static interface
WTable.TableModel
TableModel provides the data for tables.static class
WTable.TableRepeater
This repeater extension is necessary to ensure that tree-tables are painted correctly.static class
WTable.Type
This is used to control how table data should be displayed.static class
WTable.WTableComponentModel
Contains 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 String
ROW_ID_CONTEXT_PREFIX
Prefix used in row ids.static String
SELECTION_ACTION_COMMAND
Selection 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 void
addAction(WButton button)
Adds a component to the set of table actions.void
addActionConstraint(WButton button, WTable.ActionConstraint constraint)
Adds a constraint to when the given action can be used.void
addColumn(WTableColumn column)
Adds a column to the table.protected void
addPrevExpandedRow(Object rowKey)
Track the row keys that have been expanded.protected void
addPrevRenderedRow(Object rowKey)
Track the row keys that have been rendered.protected void
clearPrevExpandedRows()
Clear the previously expanded row keys.protected void
clearPrevRenderedRows()
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.String
getCaption()
WComponent
getChildAt(int index)
Retrieves a child component by its index.int
getChildCount()
List<WComponent>
getChildren()
Retrieves a list of this Container's.WTableColumn
getColumn(int index)
Retrieves the column at the specified index.int
getColumnCount()
Returns the number of columns contained in this table.int[]
getColumnOrder()
protected WTable.WTableComponentModel
getComponentModel()
Returns the effective component model for this component.int
getCurrentPage()
Set<?>
getExpandedRows()
Retrieve the row keys that are expanded.WTable.ExpandMode
getExpandMode()
int
getIndexOfChild(WComponent childComponent)
Retrieves the index of the given child.Margin
getMargin()
Get the margin for the component, or null if not set.String
getNamingContextId()
Allow components that implementNamingContextable
to selectively disable prepending their ID to their descendent's IDs by breaking the prepending logic into a seperately callable method.String
getNoDataMessage()
protected WTable.WTableComponentModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.WTable.PaginationLocation
getPaginationLocation()
WTable.PaginationMode
getPaginationMode()
protected Set<?>
getPrevExpandedRows()
Return the row keys that have been expanded.protected Set<?>
getPrevRenderedRows()
Return the row keys that have been rendered.WTable.TableRepeater
getRepeater()
protected String
getRowIdName(List<Integer> rowIndex, Object rowKey)
Allows a subclass to provide the ID used in the row naming context.int
getRowsPerPage()
The number of rows to display per page.List<Integer>
getRowsPerPageOptions()
WTable.SelectAllType
getSelectAllMode()
Indicates how the table row "select all" function should be displayed.Set<?>
getSelectedRows()
Retrieve the row keys that are selected.Action
getSelectionChangeAction()
WTable.SelectMode
getSelectMode()
WTable.SeparatorType
getSeparatorType()
int
getSortColumnIndex()
WTable.SortMode
getSortMode()
WTable.StripingType
getStripingType()
String
getSummary()
Deprecated.the summary field has been removed from the client side.WTable.TableModel
getTableModel()
WTable.Type
getType()
void
handleDataChanged()
Method to call when the model data has changed.void
handleRequest(Request request)
Override handleRequest to add table-specific functionality such as pagination and row selection.boolean
isEditable()
For tables that are editable, extra details about each row must be stored to allow them to be updated.boolean
isExpandAll()
Indicates whether the "expand all" control should be available.boolean
isNamingContext()
A naming context is only considered active if an Id name has been set.boolean
isPaginated()
protected boolean
isPresent(Request request)
Indicates whether this table was present in the request.boolean
isRenderColumnFooters()
Control if column footers should be rendered.boolean
isRowHeaders()
boolean
isShowColumnHeaders()
Indicates whether table column headers should be displayed.boolean
isSortable()
Indicates whether the table supports sorting.boolean
isSortAscending()
Indicates whether the sort on this table is ascending.boolean
isSorted()
boolean
isToggleSubRowSelection()
Indicates whether de/selecting a row with sub row(s) will de/select the sub row(s).protected WTable.WTableComponentModel
newComponentModel()
Creates a new component model.void
setCaption(String caption)
Sets the table caption text.void
setColumnOrder(int[] columnOrder)
Provide an array of column indexes in the order they should be rendered.void
setCurrentPage(int currentPage)
void
setEditable(boolean editable)
Sets the table to be editable.void
setExpandAll(boolean expandAll)
Sets whether the "expand all" control should be available.void
setExpandedRows(Set<?> rowKeys)
Set the row keys that are expanded.void
setExpandMode(WTable.ExpandMode expandMode)
Sets the row expansion mode.void
setMargin(Margin margin)
Set the margin for the component, or null for no margin.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)
.void
setNoDataMessage(String noDataMessage)
Sets the message to display when the table contains no rows.void
setPaginationLocation(WTable.PaginationLocation location)
Sets the location in the table to show the pagination controls.void
setPaginationMode(WTable.PaginationMode paginationMode)
Sets the pagination mode.void
setRenderColumnFooters(boolean renderColumnFooters)
void
setRowHeaders(boolean rowHeaders)
Set the table as having row headers.void
setRowsPerPage(int rowsPerPage)
Sets the number of rows to display per page when pagination is enabled.void
setRowsPerPageOptions(List<Integer> rowsPerPageOptions)
Set the rows per page options.void
setSelectAllMode(WTable.SelectAllType selectAllMode)
Sets how the table row "select all" function should be displayed.void
setSelectedRows(Set<?> rowKeys)
Set the row keys that are selected.void
setSelectionChangeAction(Action selectionChangeAction)
Sets the action to execute when row selection changes.void
setSelectMode(WTable.SelectMode selectMode)
Sets the row selection mode.void
setSeparatorType(WTable.SeparatorType separatorType)
Sets the separator used to visually separate rows or columns.void
setShowColumnHeaders(boolean showColumnHeaders)
Sets whether table column headers should be displayed.protected void
setSort(int index, boolean ascending)
For rendering purposes only - has no effect on model.void
setSortMode(WTable.SortMode sortMode)
Sets the table sort mode.void
setStripingType(WTable.StripingType stripingType)
Sets the striping type used to highlight alternate rows or columns.void
setSummary(String summary)
Deprecated.the summary field has been removed from the client side.void
setTableModel(WTable.TableModel tableModel)
Sets the table model which provides the row/column data.void
setToggleSubRowSelection(boolean toggleSubRowSelection)
Sets whether the de/selection of a row with sub rows should de/select the sub rows.void
setType(WTable.Type type)
Sets the table type that controls how the table is displayed.void
sort(int sortCol, boolean sortAsc)
Sort the table data by the specified column.String
toString()
Creates a String representation of this component; usually for debugging purposes.void
updateBeanValue()
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:
updateBeanValue
in 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:
setMargin
in 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:
getMargin
in 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:
handleRequest
in interfaceWComponent
- Overrides:
handleRequest
in 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:
getChildCount
in 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:
getChildAt
in 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:
getIndexOfChild
in 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:
getChildren
in interfaceContainer
- Returns:
- an immutable list of this Container.
-
toString
public String toString()
Description copied from class:AbstractWComponent
Creates a String representation of this component; usually for debugging purposes.- Overrides:
toString
in 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:
isNamingContext
in interfaceNamingContextable
- Returns:
- true if active naming context.
-
getNamingContextId
public String getNamingContextId()
Allow components that implementNamingContextable
to 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:
getNamingContextId
in interfaceNamingContextable
- Returns:
- by default, return getId().
-
newComponentModel
protected WTable.WTableComponentModel newComponentModel()
Creates a new component model.- Overrides:
newComponentModel
in 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:
getComponentModel
in 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:
getOrCreateComponentModel
in classWBeanComponent
- Returns:
- the model for this component
-
-