Top Description Inners Fields Constructors Methods
jakarta.faces.component

public Class UIData

Additional top-level classes in compilation unit: SavedState, WrapperEvent.

extends UIComponentBase
implements NamingContainer, UniqueIdVendor
Class Inheritance
All Implemented Interfaces
jakarta.faces.component.UniqueIdVendor, jakarta.faces.component.NamingContainer
Known Direct Subclasses
jakarta.faces.component.html.HtmlDataTable
Static Imports
com.sun.faces.facelets.tag.faces.ComponentSupport.restoreFullDescendantComponentDeltaStates, .ComponentSupport.restoreFullDescendantComponentStates, .ComponentSupport.restoreTransientDescendantComponentStates, .ComponentSupport.saveDescendantComponentStates, .ComponentSupport.saveDescendantInitialComponentStates, com.sun.faces.util.Util.extractFirstNumericSegment, .Util.isNestedInIterator

UIData is a UIComponent that supports data binding to a collection of data objects represented by a DataModel instance, which is the current value of this component itself (typically established via a ValueExpression). During iterative processing over the rows of data in the data model, the object for the current row is exposed as a request attribute under the key specified by the var property.

Only children of type UIColumn should be processed by renderers associated with this component.

By default, the rendererType property is set to jakarta.faces.Table. This value can be changed by calling the setRendererType() method.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static enum
UIData.PropertyKeys

Properties that are tracked by state saving.

Field Summary

Modifier and TypeField and Description
private Object
private Map<String, Object>
private Map<String, Object>
private String
baseClientId

Holds the base client ID that will be used to generate per-row client IDs (this will be null if this UIData is nested within another).

private int
baseClientIdLength

Length of the cached baseClientId plus one for the UINamingContainer#getSeparatorChar.

private StringBuilder
clientIdBuilder

StringBuilder used to build per-row client IDs.

public static final String
COMPONENT_FAMILY

The standard component family for this component.

public static final String
COMPONENT_TYPE

The standard component type for this component.

private static final ListDataModel<E>
private Boolean
isNested

Flag indicating whether or not this UIData instance is nested within another UIData instance

This is not part of the component state.

private DataModel<E>
model

The DataModel associated with this component, lazily instantiated if requested.

private Object
oldVar

During iteration through the rows of this table, This ivar is used to store the previous "var" value for this instance.

Constructor Summary

AccessConstructor and Description
public
UIData()

Create a new UIData instance with default property values.

Method Summary

Modifier and TypeMethod and Description
public void
broadcast(FacesEvent
The FacesEvent to be broadcast
event
)

Overrides jakarta.faces.component.UIComponentBase.broadcast.

Override the default UIComponentBase#broadcast processing to unwrap any wrapped FacesEvent and reset the current row index, before the event is actually broadcast.

private boolean
private DataModel<?>
createDataModel(final Class<?> forClass)

public String
createUniqueId(FacesContext
FacesContext
context
,
String
an optional seed value - e.g. based on the position of the component in the VDL-template
seed
)

Implements jakarta.faces.component.UniqueIdVendor.createUniqueId.

Generate an identifier for a component.

private boolean
doVisitChildren(VisitContext context, boolean visitRows)

public void
encodeBegin(FacesContext
FacesContext for the current request
context
)

Overrides jakarta.faces.component.UIComponentBase.encodeBegin.

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.

public String
getClientId(FacesContext
The FacesContext for the current request
context
)

Overrides jakarta.faces.component.UIComponentBase.getClientId.

Return a client identifier for this component that includes the current value of the rowIndex property, if it is not set to -1.

protected DataModel<E>

Returns:

the data model.
getDataModel
()

Return the internal DataModel object representing the data objects that we will iterate over in this component's rendering.

private Map<Class<?>, Class<? extends DataModel<?>>>
public String
getFamily()

Implements abstract jakarta.faces.component.UIComponent.getFamily.

Return the identifier of the component family to which this component belongs.

public int

Returns:

the row number.
getFirst
()

Return the zero-relative row number of the first row to be displayed.

public UIComponent

Returns:

the footer facet.
getFooter
()

Return the footer facet of this component (if any).

public UIComponent

Returns:

the header facet.
getHeader
()

Return the header facet of this component (if any).

public int

Returns:

the row count.
getRowCount
()

Return the number of rows in the underlying data model.

public Object

Returns:

the row data.
getRowData
()

Return the data object representing the data for the currently selected row index, if any.

public int

Returns:

the row index.
getRowIndex
()

Return the zero-relative index of the currently selected row.

public int

Returns:

the number of rows.
getRows
()

Return the number of rows to be displayed, or zero for all remaining rows in the table.

public Object

Returns:

the object for the value.
getValue
()

Return the value of the UIData.

public String

Returns:

he request-scope attribute.
getVar
()

Return the request-scope attribute under which the data object for the current row will be exposed when iterating.

public boolean
invokeOnComponent(FacesContext
the FacesContext for the current request
context
,
String
the client identifier of the component to be passed to the argument callback.
clientId
,
ContextCallback
an implementation of the Callback interface.
callback
)

Overrides jakarta.faces.component.UIComponentBase.invokeOnComponent.

Override behavior from UIComponentBase#invokeOnComponent to provide special care for positioning the data properly before finding the component and invoking the callback on it.

private Boolean
public boolean

Returns:

whether the row is available.
isRowAvailable
()

Return a flag indicating whether there is rowData available at the current rowIndex.

public boolean

Returns:

the value of the rowStatePreserved.
isRowStatePreserved
()

Return the value of the rowStatePreserved JavaBeans property.

private void
iterate(FacesContext
FacesContext for the current request
context
,
PhaseId
PhaseId of the phase we are currently running
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.
private boolean
keepSaved(FacesContext
FacesContext for the current request
context
)

Return true if we need to keep the saved per-child state information.

public void
markInitialState()

Overrides jakarta.faces.component.UIComponentBase.markInitialState.

Implements jakarta.faces.component.PartialStateHolder.markInitialState.

Override the base class method to take special action if the method is being invoked when StateManager#IS_BUILDING_INITIAL_STATE is true and the rowStatePreserved JavaBeans property for this instance is true.

private void
private void
private void
private void
public void
processDecodes(FacesContext
FacesContext for the current request
context
)

Overrides jakarta.faces.component.UIComponentBase.processDecodes.

Override the default UIComponentBase#processDecodes processing to perform the following steps.

public void
processUpdates(FacesContext
FacesContext for the current request
context
)

Overrides jakarta.faces.component.UIComponentBase.processUpdates.

Override the default UIComponentBase#processUpdates processing to perform the following steps.

public void
processValidators(FacesContext
FacesContext for the current request
context
)

Overrides jakarta.faces.component.UIComponentBase.processValidators.

Override the default UIComponentBase#processValidators processing to perform the following steps.

public void
queueEvent(FacesEvent
FacesEvent to be queued
event
)

Overrides jakarta.faces.component.UIComponentBase.queueEvent.

Override the default UIComponentBase#queueEvent processing to wrap any queued events in a wrapper so that we can reset the current row index in broadcast().

private boolean

Returns:

true if row index manipulation is required by the visit to this UIData instance
requiresRowIteration
(VisitContext
the FacesContext for the current request
ctx
)

Called by UIData#visitTree to determine whether or not the visitTree implementation should visit the rows of UIData or by manipulating the row index before visiting the components themselves.

private void
private void
restoreDescendantState()

Restore state information for all descendant components, as described for setRowIndex().

private void
restoreDescendantState(UIComponent
Component for which to restore state information
component
,
FacesContext
FacesContext for the current request
context
)

Restore state information for the specified component and its descendants.

public void
restoreState(FacesContext
the Faces context.
context
,
Object
the state.
state
)

Overrides jakarta.faces.component.UIComponentBase.restoreState.

Implements jakarta.faces.component.StateHolder.restoreState.

Perform any processing required to restore the state from the entries in the state Object.

private void
saveDescendantState()

Save state information for all descendant components, as described for setRowIndex().

private void
saveDescendantState(UIComponent
Component for which to save state information
component
,
FacesContext
FacesContext for the current request
context
)

Save state information for the specified component and its descendants.

public Object
saveState(FacesContext
the Faces context.
context
)

Overrides jakarta.faces.component.UIComponentBase.saveState.

Implements jakarta.faces.component.StateHolder.saveState.

Gets the state of the instance as a Serializable Object.

protected void
setDataModel(DataModel<E>
the new DataModel or null to cause the model to be refreshed.
dataModel
)

Set the internal DataModel.

public void
setFirst(int
New first row number
first
)

Set the zero-relative row number of the first row to be displayed.

public void
setFooter(UIComponent
the new footer facet
footer
)

Set the footer facet of this component.

public void
setHeader(UIComponent
the new header facet
header
)

Set the header facet of this component.

public void
setRowIndex(int
The new row index value, or -1 for no associated row
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.

private void
private void
public void
setRows(int
New number of rows
rows
)

Set the number of rows to be displayed, or zero for all remaining rows in the table.

public void
setRowStatePreserved(boolean
the flag if the state should be preserved.
preserveComponentState
)

If this property is set to true, the UIData must take steps to ensure that modifications to its iterated children will be preserved on a per-row basis.

public void
setValue(Object
the new value
value
)

Set the value of the UIData.

public void
setValueExpression(String
Name of the attribute or property for which to set a ValueExpression
name
,
ValueExpression
The ValueExpression to set, or null to remove any currently set ValueExpression
binding
)

Overrides jakarta.faces.component.UIComponent.setValueExpression.

Set the ValueExpression used to calculate the value for the specified attribute or property name, if any.

public void
setVar(String
The new request-scope attribute name
var
)

Set the request-scope attribute under which the data object for the current row wil be exposed when iterating.

private boolean
visitColumnsAndColumnFacets(VisitContext context, VisitCallback callback, boolean visitRows)

private boolean
visitFacets(VisitContext context, VisitCallback callback, boolean visitRows)

private boolean
visitRows(VisitContext context, VisitCallback callback, boolean visitRows)

public boolean
visitTree(VisitContext
the VisitContext that provides context for performing the visit.
context
,
VisitCallback
the callback to be invoked for each node encountered in the visit.
callback
)

Overrides jakarta.faces.component.UIComponent.visitTree.

Override the behavior in UIComponent#visitTree to handle iteration correctly.

Inherited from jakarta.faces.component.UIComponentBase:
addClientBehavioraddFacesListenerclearInitialStatedecodeencodeChildrenencodeEndfindComponentgetAttributesgetChildCountgetChildrengetClientBehaviorsgetDefaultEventNamegetDescriptorMapgetEventNamesgetFacesContextgetFacesListenersgetFacetgetFacetCountgetFacetsgetFacetsAndChildrengetIdgetListenersForEventClassgetParentgetPassThroughAttributesgetRenderergetRendererTypegetRendersChildrenisRenderedisTransientprocessRestoreStateprocessSaveStateremoveFacesListenerrestoreAttachedStatesaveAttachedStatesetIdsetParentsetRenderedsetRendererTypesetTransientsubscribeToEventunsubscribeFromEvent