public class DataTable extends HtmlDataTable implements IExtendedTable, ITableRowStateHolder, IDynamicComponent
Modifier and Type | Class and Description |
---|---|
static class |
DataTable.ExportActionEvent
Special event .
|
static class |
DataTable.ExportActionListener
Exports table as directed by
DataTable.ExportActionEvent . |
IExtendedTable.RowMovement
Modifier and Type | Field and Description |
---|---|
protected ITableContentProvider |
content
The
ITableContentProvider associated with this component, lazily instantiated
if requested. |
protected int |
lazyRowIndex
Row Index to use when the content provider becomes available
|
protected static int |
NO_LAZY_INDEX
Constant to indicate that there is no lazy row index to set.
|
protected String[] |
rowsToCreate
(unqualified, client) ids of rows to create.
|
protected String[] |
rowsToDelete
(unqualified, client) ids of rows to delete.
|
protected IExtendedTable.RowMovement[] |
rowsToMove
(unqualified, client) ids by new indicies of rows to move.
|
protected String[] |
rowsToUpdate
(unqualified, client) ids of rows to update.
|
protected Map<String,Object> |
saved
This map contains
SavedState instances for each descendant
component, keyed by the client identifier of the descendant. |
protected boolean |
skipRowIndexLookup
To workaround issues creating the clientId of table rows after
upgrade to JSF 2.x
|
protected SortInfo |
sortIds
Temporary sort info with sort ids.
|
protected SortInfo |
sortKeys
Temporary sort info with sort keys.
|
protected String |
templateRowId
Pseudo-id of current row to create, or null to use normal row index.
|
static String |
TYPE
New CAF specific renderer-type
|
COMPONENT_TYPE
COMPONENT_FAMILY
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
SEPARATOR_CHAR
Constructor and Description |
---|
DataTable() |
Modifier and Type | Method and Description |
---|---|
void |
broadcast(FacesEvent event)
Override the default
UIComponentBase.broadcast(javax.faces.event.FacesEvent) processing to
unwrap any wrapped FacesEvent and reset the current row index,
before the event is actually broadcast. |
protected void |
clearContent()
Clear cached content.
|
protected void |
clearDescendantState(UIComponent component,
FacesContext context)
Clears out the cached clientId for descendant controls when the current row
is invalid.
|
Collection<String> |
convertCreatedToOriginalRowIds(Collection<String> ids)
Converts actual row ids to the original client-generated ids
(ie from "myRowOne" to "__new1234").
|
Collection<String> |
convertOriginalToCreatedRowIds(Collection<String> ids)
Converts client-generated ids to the actual row ids
(ie from "__new1234" to "myRowOne").
|
void |
encodeBegin(FacesContext context)
In addition to the default behavior, ensure that any saved per-row state
for our child input components is discarded unless it is needed to
rerender the current page with errors.
|
protected void |
filter()
Filters the content provider according to the state
of the table's filter property.
|
protected String |
fromClientRowId(String id)
Remove client row id prefix.
|
boolean |
getCanTemplateRow()
True if provider can be put into template row state.
|
String |
getClientId(FacesContext context)
Return a client identifier for this component that includes the current
value of the
rowIndex property, if it is not set to -1. |
ITableContentProvider |
getContentProvider()
Lazily gets table-content-provider,
wrapping raw value if necessary.
|
protected ITableContentProvider |
getContentProvider(boolean applyLazyRowIndex)
Lazily gets table-content-provider,
wrapping raw value if necessary.
|
protected UIComponent |
getExportSettings()
Control which handles table's export settings.
|
String |
getFilter()
Filter expression.
|
int |
getFirst()
Return the zero-relative row number of the first row to be displayed.
|
int |
getRowCount()
Return the number of rows in the underlying data model.
|
Object |
getRowData()
Return the data object representing the data for the currently selected
row index, if any.
|
String |
getRowId()
Get unique identifier for the current row.
|
int |
getRowIndex()
Return the zero-relative index of the currently selected row.
|
int |
getRows()
Return the number of rows to be displayed, or zero for all remaining rows
in the table.
|
String[] |
getRowsToCreate()
List of pseudo-ids (used for client-id in place of row index)
of new rows to create, or null.
|
String[] |
getRowsToDelete()
List of ids of rows to delete, or null.
|
IExtendedTable.RowMovement[] |
getRowsToMove()
List of ids to move by list of to move in front of.
|
String[] |
getRowsToUpdate()
List of ids of rows to update, or null.
|
ISortInfo |
getSortInfo(boolean keysNotColumnIds)
Current sort info.
|
Object |
getTableRowState()
Gets this control's per-row state.
|
protected boolean |
isNestedWithinUIData() |
boolean |
isRowAvailable()
Return a flag indicating whether there is
rowData
available at the current rowIndex . |
boolean |
isTemplateRow()
Is provider in state where it returns properties for template pseudo-row.
|
protected void |
iterate(FacesContext context,
PhaseId phaseId)
Perform the appropriate phase-specific processing and per-row iteration
for the specified phase, as follows:
Set the
rowIndex property to -1, and process the
facets of this UIData component exactly once.
Set the rowIndex property to -1, and process the
facets of the UIColumn children of this UIData component
exactly once.
Iterate over the relevant rows, based on the first
and row properties, and process the children of the
UIColumn children of this UIData component once per row.
|
protected boolean |
keepSaved(FacesContext context)
Return
true if we need to keep the saved per-child state
information. |
void |
populateInitialComponents()
Perform the initial programmatic manipulation of the component
tree.
|
protected void |
prepareForEncode(FacesContext context)
Sub-classes may override to prepare their controls for encoding.
|
protected void |
processColumnChild(FacesContext context,
UIComponent component,
PhaseId phaseId)
Process column child, as appropriate for specified phase.
|
void |
processDecodes(FacesContext context)
Override the default
UIComponentBase.processDecodes(javax.faces.context.FacesContext) processing to
perform the following steps. |
void |
processUpdates(FacesContext context)
Override the default
UIComponentBase.processUpdates(javax.faces.context.FacesContext) processing to
perform the following steps. |
void |
processValidators(FacesContext context)
Override the default
UIComponentBase.processValidators(javax.faces.context.FacesContext) processing
to perform the following steps. |
void |
queueEvent(FacesEvent event)
Override the default
UIComponentBase.queueEvent(javax.faces.event.FacesEvent) processing to
wrap any queued events in a wrapper so that we can reset the current row
index in broadcast() . |
void |
resetContent() |
void |
resetRowCaches()
Clear out any cached information about the rows.
|
protected void |
restoreDescendantState()
Restore state information for all descendant components, as described for
setRowIndex() . |
protected void |
restoreDescendantState(UIComponent component,
FacesContext context)
Restore state information for the specified component and its
descendants.
|
void |
restoreState(FacesContext context,
Object state) |
protected void |
saveDescendantState()
Save state information for all descendant components, as described for
setRowIndex() . |
protected void |
saveDescendantState(UIComponent component,
FacesContext context)
Save state information for the specified component and its descendants.
|
void |
setFilter(String filter)
Filter expression.
|
void |
setFirst(int first)
Set the zero-relative row number of the first row to be displayed.
|
void |
setLazyRowIndex(int rowIndex)
If the content provider has not been created yet, delay setting
the row index until it is available.
|
void |
setRowById(String id)
Set current row by id.
|
void |
setRowIndex(int rowIndex)
Set the zero relative index of the current row, or -1 to indicate that no
row is currently selected, by implementing the following algorithm.
|
void |
setRows(int rows)
Set the number of rows to be displayed, or zero for all remaining rows in
the table.
|
void |
setRowsToCreate(String[] create)
List of pseudo-ids (used for client-id in place of row index)
of new rows to create, or null.
|
void |
setRowsToDelete(String[] delete)
List of ids of rows to delete, or null.
|
void |
setRowsToMove(IExtendedTable.RowMovement[] move)
List of ids to move by list of to move in front of.
|
void |
setRowsToUpdate(String[] update)
List of ids of rows to update, or null.
|
void |
setTableRowState(Object o)
Sets this control's per-row state.
|
void |
setTemplateRow()
Sets provider to state where it returns properties for template pseudo-row.
|
protected void |
setTemplateRowId(String id)
Set pseudo-id for row to be created, making it the current row.
|
void |
setValue(Object value)
Set the value of the
UIData . |
void |
setValueBinding(String name,
ValueBinding binding)
Deprecated.
use
setValueExpression(String, ValueExpression) instead. |
void |
setValueExpression(String name,
ValueExpression binding) |
protected void |
sort()
Sorts the content provider according to the state
of the table's extended columns.
|
protected String |
toClientRowId(String id)
Add client row id prefix.
|
protected void |
updateRowsToCreate()
Update rowsToCreate, rowsToUpdate, and indiciesToCreate
by mapping original row ids to already created row ids.
|
getBgcolor, getBodyrows, getBorder, getCaptionClass, getCaptionStyle, getCellpadding, getCellspacing, getColumnClasses, getDefaultEventName, getDir, getEventNames, getFooterClass, getFrame, getHeaderClass, getLang, getOnclick, getOndblclick, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getRole, getRowClasses, getRules, getStyle, getStyleClass, getSummary, getTitle, getWidth, setBgcolor, setBodyrows, setBorder, setCaptionClass, setCaptionStyle, setCellpadding, setCellspacing, setColumnClasses, setDir, setFooterClass, setFrame, setHeaderClass, setLang, setOnclick, setOndblclick, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setRole, setRowClasses, setRules, setStyle, setStyleClass, setSummary, setTitle, setWidth
createUniqueId, getDataModel, getFamily, getFooter, getHeader, getValue, getVar, invokeOnComponent, isRowStatePreserved, markInitialState, saveState, setDataModel, setFooter, setHeader, setRowStatePreserved, setVar, visitTree
addClientBehavior, addFacesListener, clearInitialState, decode, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClientBehavior, getClientBehaviors
protected transient ITableContentProvider content
The ITableContentProvider
associated with this component, lazily instantiated
if requested. This object is not part of the saved and restored state of
the component.
protected Map<String,Object> saved
This map contains SavedState
instances for each descendant
component, keyed by the client identifier of the descendant. Because
descendant client identifiers will contain the rowIndex
value of the parent, per-row state information is actually preserved.
protected transient SortInfo sortKeys
protected transient SortInfo sortIds
protected String templateRowId
protected String[] rowsToCreate
protected IExtendedTable.RowMovement[] rowsToMove
protected String[] rowsToDelete
protected String[] rowsToUpdate
protected static final int NO_LAZY_INDEX
protected transient int lazyRowIndex
protected transient boolean skipRowIndexLookup
public static final String TYPE
public int getFirst()
Return the zero-relative row number of the first row to be displayed.
public void setFirst(int first)
Set the zero-relative row number of the first row to be displayed.
setFirst
in class UIData
first
- New first row numberIllegalArgumentException
- if first
is negativepublic boolean isRowAvailable()
Return a flag indicating whether there is rowData
available at the current rowIndex
. If no
wrappedData
is available, return false
.
isRowAvailable
in class UIData
FacesException
- if an error occurs getting the row availabilitypublic int getRowCount()
Return the number of rows in the underlying data model. If the number of available rows is unknown, return -1.
getRowCount
in class UIData
FacesException
- if an error occurs getting the row countpublic Object getRowData()
Return the data object representing the data for the currently selected row index, if any.
getRowData
in class UIData
FacesException
- if an error occurs getting the row dataIllegalArgumentException
- if now row data is available at the currently specified
row indexpublic int getRowIndex()
Return the zero-relative index of the currently selected row. If were not currently positioned on a row, return -1. This property is not enabled for value binding expressions.
getRowIndex
in class UIData
FacesException
- if an error occurs getting the row indexpublic void setLazyRowIndex(int rowIndex)
rowIndex
- the row indexpublic void setRowIndex(int rowIndex)
Set the zero relative index of the current row, or -1 to indicate that no
row is currently selected, by implementing the following algorithm. It is
possible to set the row index at a value for which the underlying data
collection does not contain any row data. Therefore, callers may use the
isRowAvailable()
method to detect whether row data will be
available for use by the getRowData()
method.
DataModel
associated with this UIData
instance.rowIndex
value is -1:
var
property is not null, remove the
corresponding request scope attribute (if any).rowIndex
value is not -1:
var
property is not null, call
getRowData()
and expose the resulting data object as a
request scope attribute whose key is the var
property
value.
To save current state information for all descendant components,
UIData
must maintain per-row information for each descendant as
follows:
EditableValueHolder
,
save the state of its localValue
property.EditableValueHolder
,
save the state of the localValueSet
property.EditableValueHolder
,
save the state of the valid
property.EditableValueHolder
,
save the state of the submittedValue
property.
To restore current state information for all descendant components,
UIData
must reference its previously stored information for the
current rowIndex
and call setters for each descendant as
follows:
EditableValueHolder
,
restore the value
property.EditableValueHolder
,
restore the state of the localValueSet
property.EditableValueHolder
,
restore the state of the valid
property.EditableValueHolder
,
restore the state of the submittedValue
property.setRowIndex
in class UIData
rowIndex
- The new row index value, or -1 for no associated rowFacesException
- if an error occurs setting the row indexIllegalArgumentException
- if rowIndex
is less than -1public int getRows()
Return the number of rows to be displayed, or zero for all remaining rows in the table. The default value of this property is zero.
public void setRows(int rows)
Set the number of rows to be displayed, or zero for all remaining rows in the table.
setRows
in class UIData
rows
- New number of rowsIllegalArgumentException
- if rows
is negativepublic void restoreState(FacesContext context, Object state)
restoreState
in interface StateHolder
restoreState
in class UIData
public void setValue(Object value)
@Deprecated public void setValueBinding(String name, ValueBinding binding)
setValueExpression(String, ValueExpression)
instead.
Set the ValueBinding
used to calculate the value for the
specified attribute or property name, if any. In addition, if a
ValueBinding
is set for the value
property, remove
any synthesized DataModel
for the data previously bound to this
component.
setValueBinding
in class UIData
name
- Name of the attribute or property for which to set a
ValueBinding
binding
- The ValueBinding
to set, or null
to
remove any currently set ValueBinding
IllegalArgumentException
- if name
is one of id
,
parent
, var
, or
rowIndex
NullPointerException
- if name
is null
public void setValueExpression(String name, ValueExpression binding)
setValueExpression
in class UIData
public String getClientId(FacesContext context)
Return a client identifier for this component that includes the current
value of the rowIndex
property, if it is not set to -1.
This implies that multiple calls to getClientId()
may
return different results, but ensures that child components can
themselves generate row-specific client identifiers (since UIData
is a NamingContainer
).
getClientId
in class UIData
NullPointerException
- if context
is null
public void queueEvent(FacesEvent event)
Override the default UIComponentBase.queueEvent(javax.faces.event.FacesEvent)
processing to
wrap any queued events in a wrapper so that we can reset the current row
index in broadcast()
.
queueEvent
in class UIData
event
- FacesEvent
to be queuedIllegalStateException
- if this component is not a descendant of a
UIViewRoot
NullPointerException
- if event
is null
public void broadcast(FacesEvent event) throws AbortProcessingException
Override the default UIComponentBase.broadcast(javax.faces.event.FacesEvent)
processing to
unwrap any wrapped FacesEvent
and reset the current row index,
before the event is actually broadcast. For events that we did not wrap
(in queueEvent()
), default processing will occur.
broadcast
in class UIData
event
- The FacesEvent
to be broadcastAbortProcessingException
- Signal the JavaServer Faces implementation that no further
processing on the current event should be performedIllegalArgumentException
- if the implementation class of this FacesEvent
is
not supported by this componentNullPointerException
- if event
is null
public void encodeBegin(FacesContext context) throws IOException
In addition to the default behavior, ensure that any saved per-row state for our child input components is discarded unless it is needed to rerender the current page with errors.
encodeBegin
in class UIData
context
- FacesContext for the current requestIOException
- if an input/output error occurs while renderingNullPointerException
- if context
is null
protected void prepareForEncode(FacesContext context)
context
- FacesContext for the current requestpublic void processDecodes(FacesContext context)
Override the default UIComponentBase.processDecodes(javax.faces.context.FacesContext)
processing to
perform the following steps.
rendered
property of this UIComponent
is false
, skip further processing.rowIndex
to -1.processDecodes()
method of all facets of
this UIData
, in the order determined by a call to
getFacets().keySet().iterator()
.processDecodes()
method of all facets of the
UIColumn
children of this UIData
.first
and
rows
properties), performing the following processing for
each row:
rowIndex
to -1.decode()
method of this component.RuntimeException
is thrown during decode
processing, call FacesContext.renderResponse()
and re-throw the
exception.processDecodes
in class UIData
context
- FacesContext
for the current requestNullPointerException
- if context
is null
public void processValidators(FacesContext context)
Override the default UIComponentBase.processValidators(javax.faces.context.FacesContext)
processing
to perform the following steps.
rendered
property of this UIComponent
is false
, skip further processing.rowIndex
to -1.processValidators()
method of all facets of
this UIData
, in the order determined by a call to
getFacets().keySet().iterator()
.processValidators()
method of all facets of
the UIColumn
children of this UIData
.first
and
rows
properties), performing the following processing for
each row:
rowIndex
to -1.processValidators
in class UIData
context
- FacesContext
for the current requestNullPointerException
- if context
is null
public void processUpdates(FacesContext context)
Override the default UIComponentBase.processUpdates(javax.faces.context.FacesContext)
processing to
perform the following steps.
rendered
property of this UIComponent
is false
, skip further processing.rowIndex
to -1.processUpdates()
method of all facets of
this UIData
, in the order determined by a call to
getFacets().keySet().iterator()
.processUpdates()
method of all facets of the
UIColumn
children of this UIData
.first
and
rows
properties), performing the following processing for
each row:
rowIndex
to -1.processUpdates
in class UIData
context
- FacesContext
for the current requestNullPointerException
- if context
is null
public Object getTableRowState()
getTableRowState
in interface ITableRowStateHolder
public void setTableRowState(Object o)
setTableRowState
in interface ITableRowStateHolder
public ISortInfo getSortInfo(boolean keysNotColumnIds)
IExtendedTable
getSortInfo
in interface IExtendedTable
keysNotColumnIds
- True to report keys using column "sort" property,
false to report keys using column ids.public String getRowId()
IExtendedTable
getRowId
in interface IExtendedTable
public void setRowById(String id)
IExtendedTable
setRowById
in interface IExtendedTable
public boolean getCanTemplateRow()
IExtendedTable
getCanTemplateRow
in interface IExtendedTable
IExtendedTable.setTemplateRow()
public boolean isTemplateRow()
IExtendedTable
isTemplateRow
in interface IExtendedTable
public void setTemplateRow()
IExtendedTable
setTemplateRow
in interface IExtendedTable
protected void updateRowsToCreate()
public String[] getRowsToCreate()
IExtendedTable
getRowsToCreate
in interface IExtendedTable
public void setRowsToCreate(String[] create)
IExtendedTable
setRowsToCreate
in interface IExtendedTable
public IExtendedTable.RowMovement[] getRowsToMove()
IExtendedTable
getRowsToMove
in interface IExtendedTable
public void setRowsToMove(IExtendedTable.RowMovement[] move)
IExtendedTable
setRowsToMove
in interface IExtendedTable
public String[] getRowsToDelete()
IExtendedTable
getRowsToDelete
in interface IExtendedTable
public void setRowsToDelete(String[] delete)
IExtendedTable
setRowsToDelete
in interface IExtendedTable
public String[] getRowsToUpdate()
IExtendedTable
getRowsToUpdate
in interface IExtendedTable
public void setRowsToUpdate(String[] update)
IExtendedTable
setRowsToUpdate
in interface IExtendedTable
public Collection<String> convertOriginalToCreatedRowIds(Collection<String> ids)
IExtendedTable
convertOriginalToCreatedRowIds
in interface IExtendedTable
public Collection<String> convertCreatedToOriginalRowIds(Collection<String> ids)
IExtendedTable
convertCreatedToOriginalRowIds
in interface IExtendedTable
public String getFilter()
IExtendedTable
getFilter
in interface IExtendedTable
public void setFilter(String filter)
IExtendedTable
setFilter
in interface IExtendedTable
public void resetRowCaches()
IExtendedTable
resetRowCaches
in interface IExtendedTable
protected void iterate(FacesContext context, PhaseId phaseId)
Perform the appropriate phase-specific processing and per-row iteration for the specified phase, as follows:
rowIndex
property to -1, and process the
facets of this UIData
component exactly once.rowIndex
property to -1, and process the
facets of the UIColumn
children of this UIData
component
exactly once.first
and row
properties, and process the children of the
UIColumn
children of this UIData
component once per row.context
- FacesContext
for the current requestphaseId
- PhaseId
of the phase we are currently runningprotected void processColumnChild(FacesContext context, UIComponent component, PhaseId phaseId)
protected void setTemplateRowId(String id)
protected boolean keepSaved(FacesContext context)
Return true
if we need to keep the saved per-child state
information. This will be the case if any of the following are true:
UIData
instance is nested inside of another
UIData
instancecontext
- FacesContext
for the current requestprotected boolean isNestedWithinUIData()
protected void restoreDescendantState()
Restore state information for all descendant components, as described for
setRowIndex()
.
protected void clearDescendantState(UIComponent component, FacesContext context)
protected void restoreDescendantState(UIComponent component, FacesContext context)
Restore state information for the specified component and its descendants.
component
- Component for which to restore state informationcontext
- FacesContext
for the current requestprotected void saveDescendantState()
Save state information for all descendant components, as described for
setRowIndex()
.
protected void saveDescendantState(UIComponent component, FacesContext context)
Save state information for the specified component and its descendants.
component
- Component for which to save state informationcontext
- FacesContext
for the current requestpublic ITableContentProvider getContentProvider()
getContentProvider
in interface IExtendedTable
protected ITableContentProvider getContentProvider(boolean applyLazyRowIndex)
applyLazyRowIndex
- Apply the lazy row index if it is available.protected void clearContent()
public void resetContent()
protected void sort()
protected void filter()
protected UIComponent getExportSettings()
public void populateInitialComponents()
IDynamicComponent
populateInitialComponents
in interface IDynamicComponent