Class UIData
- java.lang.Object
-
- jakarta.faces.component.UIComponent
-
- jakarta.faces.component.UIComponentBase
-
- jakarta.faces.component.UIData
-
- All Implemented Interfaces:
NamingContainer,PartialStateHolder,StateHolder,TransientStateHolder,UniqueIdVendor,ComponentSystemEventListener,FacesListener,SystemEventListenerHolder,EventListener
- Direct Known Subclasses:
HtmlDataTable
public class UIData extends UIComponentBase implements NamingContainer, UniqueIdVendor
UIData is a
UIComponentthat supports data binding to a collection of data objects represented by aDataModelinstance, which is the current value of this component itself (typically established via aValueExpression). 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 thevarproperty.Only children of type
UIColumnshould be processed by renderers associated with this component.By default, the
rendererTypeproperty is set tojakarta.faces.Table. This value can be changed by calling thesetRendererType()method.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOMPONENT_FAMILYThe standard component family for this component.static StringCOMPONENT_TYPEThe standard component type for this component.-
Fields inherited from class jakarta.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEY
-
Fields inherited from interface jakarta.faces.component.NamingContainer
SEPARATOR_CHAR
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbroadcast(FacesEvent event)Override the defaultUIComponentBase.broadcast(jakarta.faces.event.FacesEvent)processing to unwrap any wrappedFacesEventand reset the current row index, before the event is actually broadcast.StringcreateUniqueId(FacesContext context, String seed)Generate an identifier for a component.voidencodeBegin(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.StringgetClientId(FacesContext context)Return a client identifier for this component that includes the current value of therowIndexproperty, if it is not set to -1.protected DataModelgetDataModel()Return the internalDataModelobject representing the data objects that we will iterate over in this component's rendering.StringgetFamily()Return the identifier of the component family to which this component belongs.intgetFirst()Return the zero-relative row number of the first row to be displayed.UIComponentgetFooter()Return the footer facet of this component (if any).UIComponentgetHeader()Return the header facet of this component (if any).intgetRowCount()Return the number of rows in the underlying data model.ObjectgetRowData()Return the data object representing the data for the currently selected row index, if any.intgetRowIndex()Return the zero-relative index of the currently selected row.intgetRows()Return the number of rows to be displayed, or zero for all remaining rows in the table.ObjectgetValue()Return the value of the UIData.StringgetVar()Return the request-scope attribute under which the data object for the current row will be exposed when iterating.booleaninvokeOnComponent(FacesContext context, String clientId, ContextCallback callback)Override behavior fromUIComponentBase.invokeOnComponent(jakarta.faces.context.FacesContext, java.lang.String, jakarta.faces.component.ContextCallback)to provide special care for positioning the data properly before finding the component and invoking the callback on it.booleanisRowAvailable()Return a flag indicating whether there isrowDataavailable at the currentrowIndex.booleanisRowStatePreserved()Return the value of therowStatePreservedJavaBeans property.voidmarkInitialState()Override the base class method to take special action if the method is being invoked whenStateManager.IS_BUILDING_INITIAL_STATEis true and therowStatePreservedJavaBeans property for this instance istrue.voidprocessDecodes(FacesContext context)Override the defaultUIComponentBase.processDecodes(jakarta.faces.context.FacesContext)processing to perform the following steps.voidprocessUpdates(FacesContext context)Override the defaultUIComponentBase.processUpdates(jakarta.faces.context.FacesContext)processing to perform the following steps.voidprocessValidators(FacesContext context)Override the defaultUIComponentBase.processValidators(jakarta.faces.context.FacesContext)processing to perform the following steps.voidqueueEvent(FacesEvent event)Override the defaultUIComponentBase.queueEvent(jakarta.faces.event.FacesEvent)processing to wrap any queued events in a wrapper so that we can reset the current row index inbroadcast().voidrestoreState(FacesContext context, Object state)Perform any processing required to restore the state from the entries in the state Object.ObjectsaveState(FacesContext context)Gets the state of the instance as aSerializableObject.protected voidsetDataModel(DataModel dataModel)Set the internal DataModel.voidsetFirst(int first)Set the zero-relative row number of the first row to be displayed.voidsetFooter(UIComponent footer)Set the footer facet of this component.voidsetHeader(UIComponent header)Set the header facet of this component.voidsetRowIndex(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.voidsetRows(int rows)Set the number of rows to be displayed, or zero for all remaining rows in the table.voidsetRowStatePreserved(boolean preserveComponentState)If this property is set totrue, theUIDatamust take steps to ensure that modifications to its iterated children will be preserved on a per-row basis.voidsetValue(Object value)Set the value of theUIData.voidsetValueExpression(String name, ValueExpression binding)Set theValueExpressionused to calculate the value for the specified attribute or property name, if any.voidsetVar(String var)Set the request-scope attribute under which the data object for the current row wil be exposed when iterating.booleanvisitTree(VisitContext context, VisitCallback callback)Override the behavior inUIComponent.visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback)to handle iteration correctly.-
Methods inherited from class jakarta.faces.component.UIComponentBase
addClientBehavior, addFacesListener, clearInitialState, decode, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, subscribeToEvent, unsubscribeFromEvent
-
Methods inherited from class jakarta.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView
-
-
-
-
Field Detail
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The standard component type for this component.
- See Also:
- Constant Field Values
-
COMPONENT_FAMILY
public static final String COMPONENT_FAMILY
The standard component family for this component.
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UIData
public UIData()
Create a new
UIDatainstance with default property values.
-
-
Method Detail
-
getFamily
public String getFamily()
Description copied from class:UIComponentReturn the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the
rendererTypeproperty, may be used to select the appropriateRendererfor this component instance. Note this method should NOT returnnull- Specified by:
getFamilyin classUIComponent- Returns:
- the component family (not null).
-
getFirst
public int getFirst()
Return the zero-relative row number of the first row to be displayed.
- Returns:
- the row number.
-
setFirst
public void setFirst(int first)
Set the zero-relative row number of the first row to be displayed.
- Parameters:
first- New first row number- Throws:
IllegalArgumentException- iffirstis negative
-
getFooter
public UIComponent getFooter()
Return the footer facet of this component (if any). A convenience method for
getFacet("footer").- Returns:
- the footer facet.
-
setFooter
public void setFooter(UIComponent footer)
Set the footer facet of this component. A convenience method for
getFacets().put("footer", footer).- Parameters:
footer- the new footer facet- Throws:
NullPointerException- iffooterisnull
-
getHeader
public UIComponent getHeader()
Return the header facet of this component (if any). A convenience method for
getFacet("header").- Returns:
- the header facet.
-
setHeader
public void setHeader(UIComponent header)
Set the header facet of this component. A convenience method for
getFacets().put("header", header).- Parameters:
header- the new header facet- Throws:
NullPointerException- ifheaderisnull
-
isRowAvailable
public boolean isRowAvailable()
Return a flag indicating whether there is
rowDataavailable at the currentrowIndex. If nowrappedDatais available, returnfalse.- Returns:
- whether the row is available.
- Throws:
FacesException- if an error occurs getting the row availability
-
getRowCount
public int getRowCount()
Return the number of rows in the underlying data model. If the number of available rows is unknown, return -1.
- Returns:
- the row count.
- Throws:
FacesException- if an error occurs getting the row count
-
getRowData
public Object getRowData()
Return the data object representing the data for the currently selected row index, if any.
- Returns:
- the row data.
- Throws:
FacesException- if an error occurs getting the row dataIllegalArgumentException- if now row data is available at the currently specified row index
-
getRowIndex
public int getRowIndex()
Return the zero-relative index of the currently selected row. If we are not currently positioned on a row, return -1. This property is not enabled for value binding expressions.
- Returns:
- the row index.
- Throws:
FacesException- if an error occurs getting the row index
-
setRowIndex
public 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 thegetRowData()method.To support transient state among descendents, please consult the specification for
setRowStatePreserved(boolean), which details the requirements forsetRowIndex()when therowStatePreservedJavaBeans property is set totrue.- Save current state information for all descendant components (as described below).
- Store the new row index, and pass it on to the
DataModelassociated with thisUIDatainstance. - If the new
rowIndexvalue is -1:- If the
varproperty is not null, remove the corresponding request scope attribute (if any). - Reset the state information for all descendant components (as described below).
- If the
- If the new
rowIndexvalue is not -1:- If the
varproperty is not null, callgetRowData()and expose the resulting data object as a request scope attribute whose key is thevarproperty value. - Reset the state information for all descendant components (as described below).
- If the
To save current state information for all descendant components,
UIDatamust maintain per-row information for each descendant as follows:- If the descendant is an instance of
EditableValueHolder, save the state of itslocalValueproperty. - If the descendant is an instance of
EditableValueHolder, save the state of thelocalValueSetproperty. - If the descendant is an instance of
EditableValueHolder, save the state of thevalidproperty. - If the descendant is an instance of
EditableValueHolder, save the state of thesubmittedValueproperty.
To restore current state information for all descendant components,
UIDatamust reference its previously stored information for the currentrowIndexand call setters for each descendant as follows:- If the descendant is an instance of
EditableValueHolder, restore thevalueproperty. - If the descendant is an instance of
EditableValueHolder, restore the state of thelocalValueSetproperty. - If the descendant is an instance of
EditableValueHolder, restore the state of thevalidproperty. - If the descendant is an instance of
EditableValueHolder, restore the state of thesubmittedValueproperty.
- Parameters:
rowIndex- The new row index value, or -1 for no associated row- Throws:
FacesException- if an error occurs setting the row indexIllegalArgumentException- ifrowIndexis less than -1
-
getRows
public 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.
- Returns:
- the number of rows.
-
setRows
public void setRows(int rows)
Set the number of rows to be displayed, or zero for all remaining rows in the table.
- Parameters:
rows- New number of rows- Throws:
IllegalArgumentException- ifrowsis negative
-
getVar
public String getVar()
Return the request-scope attribute under which the data object for the current row will be exposed when iterating. This property is not enabled for value binding expressions.
- Returns:
- he request-scope attribute.
-
setVar
public void setVar(String var)
Set the request-scope attribute under which the data object for the current row wil be exposed when iterating.
- Parameters:
var- The new request-scope attribute name
-
isRowStatePreserved
public boolean isRowStatePreserved()
Return the value of the
rowStatePreservedJavaBeans property. SeesetRowStatePreserved(boolean).- Returns:
- the value of the
rowStatePreserved. - Since:
- 2.1
-
setRowStatePreserved
public void setRowStatePreserved(boolean preserveComponentState)
If this property is set to
true, theUIDatamust take steps to ensure that modifications to its iterated children will be preserved on a per-row basis. This allows applications to modify component properties, such as the style-class, for a specific row, rather than having such modifications apply to all rows.To accomplish this,
UIDatamust callStateHolder.saveState(jakarta.faces.context.FacesContext)andTransientStateHolder.saveTransientState(jakarta.faces.context.FacesContext)on its children to capture their state on exiting each row. When re-entering the row,StateHolder.restoreState(jakarta.faces.context.FacesContext, java.lang.Object)andTransientStateHolder.restoreTransientState(jakarta.faces.context.FacesContext, java.lang.Object)must be called in order to reinitialize the children to the correct state for the new row. All of this action must take place during the processing ofsetRowIndex(int).Users should consider enabling this feature for cases where it is necessary to modify properties of
UIData's children in a row-specific way. Note, however, that row-level state saving/restoring does add overhead. As such, this feature should be used judiciously.- Parameters:
preserveComponentState- the flag if the state should be preserved.- Since:
- 2.1
-
getValue
public Object getValue()
Return the value of the UIData. This value must either be be of type
DataModel, or a type that can be adapted into aDataModel.UIDatawill automatically adapt the following types:- Arrays
java.util.Listjava.sql.ResultSetjava.util.Collection
All other types will be adapted using the
ScalarDataModelclass, which will treat the object as a single row of data.- Returns:
- the object for the value.
-
setValue
public void setValue(Object value)
Set the value of the
UIData. This value must either be be of typeDataModel, or a type that can be adapted into aDataModel.- Parameters:
value- the new value
-
setValueExpression
public void setValueExpression(String name, ValueExpression binding)
Set the
ValueExpressionused to calculate the value for the specified attribute or property name, if any. In addition, if aValueExpressionis set for thevalueproperty, remove any synthesizedDataModelfor the data previously bound to this component.- Overrides:
setValueExpressionin classUIComponent- Parameters:
name- Name of the attribute or property for which to set aValueExpressionbinding- TheValueExpressionto set, ornullto remove any currently setValueExpression- Throws:
IllegalArgumentException- ifnameis one ofid,parent,var, orrowIndexNullPointerException- ifnameisnull- Since:
- 1.2
-
getClientId
public String getClientId(FacesContext context)
Return a client identifier for this component that includes the current value of the
rowIndexproperty, if it is not set to -1. This implies that multiple calls togetClientId()may return different results, but ensures that child components can themselves generate row-specific client identifiers (sinceUIDatais aNamingContainer).- Overrides:
getClientIdin classUIComponentBase- Parameters:
context- TheFacesContextfor the current request- Returns:
- the client id.
- Throws:
NullPointerException- ifcontextisnull
-
invokeOnComponent
public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback) throws FacesException
Override behavior from
UIComponentBase.invokeOnComponent(jakarta.faces.context.FacesContext, java.lang.String, jakarta.faces.component.ContextCallback)to provide special care for positioning the data properly before finding the component and invoking the callback on it. If the argumentclientIdis equal tothis.getClientId()simply invoke thecontextCallback, passing thecontextargument and this as arguments, and returntrue.If the argumentclientIdis not equal tothis.getClientId(), inspect each of the facet children of thisUIDatainstance and for each one, compare itsclientIdwith the argumentclientId. If there is a match, invoke thecontextCallback, passing thecontextargument and this as arguments, and returntrue. Otherwise, attempt to extract a rowIndex from theclientId. For example, if the argumentclientIdwasform:data:3:customerHeaderthe rowIndex would be3. Let this value be callednewIndex. The current rowIndex of this instance must be saved aside and restored before returning in all cases, regardless of the outcome of the search or if any exceptions are thrown in the process.The implementation of this method must never return
trueif setting the rowIndex of this instance to be equal tonewIndexcauses this instance to returnfalsefromisRowAvailable().- Overrides:
invokeOnComponentin classUIComponentBase- Parameters:
context- theFacesContextfor the current requestclientId- the client identifier of the component to be passed to the argument callback.callback- an implementation of the Callback interface.- Returns:
trueif the a component with the givenclientIdis found, the callback method was successfully invoked passing that component as an argument, and no Exception was thrown. Returnsfalseif no component with the givenclientIdis found.- Throws:
NullPointerException- if any of the arguments are nullFacesException- if the argument Callback throws an Exception, it is wrapped in aFacesExceptionand re-thrown. Also throwsFacesExceptionif any exception is thrown when deriving the rowIndex from the argumentclientId.- Since:
- 1.2
-
queueEvent
public void queueEvent(FacesEvent event)
Override the default
UIComponentBase.queueEvent(jakarta.faces.event.FacesEvent)processing to wrap any queued events in a wrapper so that we can reset the current row index inbroadcast().- Overrides:
queueEventin classUIComponentBase- Parameters:
event-FacesEventto be queued- Throws:
IllegalStateException- if this component is not a descendant of aUIViewRootNullPointerException- ifeventisnull
-
broadcast
public void broadcast(FacesEvent event) throws AbortProcessingException
Override the default
UIComponentBase.broadcast(jakarta.faces.event.FacesEvent)processing to unwrap any wrappedFacesEventand reset the current row index, before the event is actually broadcast. For events that we did not wrap (inqueueEvent()), default processing will occur.- Overrides:
broadcastin classUIComponentBase- Parameters:
event- TheFacesEventto be broadcast- Throws:
AbortProcessingException- Signal the Jakarta Faces implementation that no further processing on the current event should be performedIllegalArgumentException- if the implementation class of thisFacesEventis not supported by this componentNullPointerException- ifeventisnull
-
encodeBegin
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.
- Overrides:
encodeBeginin classUIComponentBase- Parameters:
context- FacesContext for the current request- Throws:
IOException- if an input/output error occurs while renderingNullPointerException- ifcontextisnull
-
processDecodes
public void processDecodes(FacesContext context)
Override the default
UIComponentBase.processDecodes(jakarta.faces.context.FacesContext)processing to perform the following steps.- If the
renderedproperty of thisUIComponentisfalse, skip further processing. - Set the current
rowIndexto -1. - Call the
processDecodes()method of all facets of thisUIData, in the order determined by a call togetFacets().keySet().iterator(). - Call the
processDecodes()method of all facets of theUIColumnchildren of thisUIData. - Iterate over the set of rows that were included when this component was rendered (i.e. those defined by the
firstandrowsproperties), performing the following processing for each row: - Set the current
rowIndexto -1. - Call the
decode()method of this component. - If a
RuntimeExceptionis thrown during decode processing, callFacesContext.renderResponse()and re-throw the exception.
- Overrides:
processDecodesin classUIComponentBase- Parameters:
context-FacesContextfor the current request- Throws:
NullPointerException- ifcontextisnull
- If the
-
processValidators
public void processValidators(FacesContext context)
Override the default
UIComponentBase.processValidators(jakarta.faces.context.FacesContext)processing to perform the following steps.- If the
renderedproperty of thisUIComponentisfalse, skip further processing. - Set the current
rowIndexto -1. - Call the
processValidators()method of all facets of thisUIData, in the order determined by a call togetFacets().keySet().iterator(). - Call the
processValidators()method of all facets of theUIColumnchildren of thisUIData. - Iterate over the set of rows that were included when this component was rendered (i.e. those defined by the
firstandrowsproperties), performing the following processing for each row: - Set the current
rowIndexto -1.
- Overrides:
processValidatorsin classUIComponentBase- Parameters:
context-FacesContextfor the current request- Throws:
NullPointerException- ifcontextisnull- See Also:
PreValidateEvent,PostValidateEvent
- If the
-
processUpdates
public void processUpdates(FacesContext context)
Override the default
UIComponentBase.processUpdates(jakarta.faces.context.FacesContext)processing to perform the following steps.- If the
renderedproperty of thisUIComponentisfalse, skip further processing. - Set the current
rowIndexto -1. - Call the
processUpdates()method of all facets of thisUIData, in the order determined by a call togetFacets().keySet().iterator(). - Call the
processUpdates()method of all facets of theUIColumnchildren of thisUIData. - Iterate over the set of rows that were included when this component was rendered (i.e. those defined by the
firstandrowsproperties), performing the following processing for each row: - Set the current
rowIndexto -1.
- Overrides:
processUpdatesin classUIComponentBase- Parameters:
context-FacesContextfor the current request- Throws:
NullPointerException- ifcontextisnull
- If the
-
createUniqueId
public String createUniqueId(FacesContext context, String seed)
Description copied from interface:UniqueIdVendorGenerate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within this component-container. Optionally, a unique seed value can be supplied by component creators which should be included in the generated unique id.
- Specified by:
createUniqueIdin interfaceUniqueIdVendor- Parameters:
context- FacesContextseed- an optional seed value - e.g. based on the position of the component in the VDL-template- Returns:
- a unique-id in this component-container
-
visitTree
public boolean visitTree(VisitContext context, VisitCallback callback)
Override the behavior in
UIComponent.visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback)to handle iteration correctly.If the
UIComponent.isVisitable(jakarta.faces.component.visit.VisitContext)method of this instance returnsfalse, take no action and return.Call
UIComponent.pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent)and invoke the visit callback on thisUIDatainstance as described inUIComponent.visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback). Let the result of the invoctaion be visitResult. If visitResult isVisitResult.COMPLETE, take no further action and returntrue. Otherwise, determine if we need to visit our children. The default implementation callsVisitContext.getSubtreeIdsToVisit(jakarta.faces.component.UIComponent)passingthisas the argument. If the result of that call is non-empty, let doVisitChildren betrue. If doVisitChildren istrueand visitResult isVisitResult.ACCEPT, take the following action.-
If this component has facets, call
UIComponent.getFacets()on this instance and invoke thevalues()method. For eachUIComponentin the returnedMap, callUIComponent.visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback). -
If this component has children, for each
UIColumnchild:Call
VisitContext.invokeVisitCallback(jakarta.faces.component.UIComponent, jakarta.faces.component.visit.VisitCallback)on thatUIColumninstance. If such a call returnstrue, terminate visiting and returntruefrom this method.If the child
UIColumnhas facets, callUIComponent.visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback)on each one.Take no action on non-
UIColumnchildren. -
Save aside the result of a call to
getRowIndex().For each child component of this
UIDatathat is also an instance ofUIColumn,Iterate over the rows.
-
Let rowsToProcess be the return from
getRows(). -
Let rowIndex be the return from
getFirst()- 1. -
While the number of rows processed is less than rowsToProcess, take the following actions.
Call
setRowIndex(int), passing the current row index.If
isRowAvailable()returnsfalse, take no further action and returnfalse.Call
UIComponent.visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback)on each of the children of thisUIColumninstance.
-
Call
UIComponent.popComponentFromEL(jakarta.faces.context.FacesContext)and restore the saved row index with a call tosetRowIndex(int).Return
falseto allow the visiting to continue.- Overrides:
visitTreein classUIComponent- Parameters:
context- theVisitContextthat provides context for performing the visit.callback- the callback to be invoked for each node encountered in the visit.- Returns:
- component implementations may return
trueto indicate that the tree visit is complete (eg. all components that need to be visited have been visited). This results in the tree visit being short-circuited such that no more components are visited. - Throws:
NullPointerException- if any of the parameters arenull.- See Also:
VisitContext.invokeVisitCallback()
-
-
markInitialState
public void markInitialState()
Override the base class method to take special action if the method is being invoked when
StateManager.IS_BUILDING_INITIAL_STATEis true and therowStatePreservedJavaBeans property for this instance istrue.The additional action taken is to traverse the descendents and save their state without regard to any particular row value.
- Specified by:
markInitialStatein interfacePartialStateHolder- Overrides:
markInitialStatein classUIComponentBase- Since:
- 2.1
-
restoreState
public void restoreState(FacesContext context, Object state)
Description copied from interface:StateHolderPerform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to instances that also implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.restoreState(jakarta.faces.context.FacesContext, java.lang.Object)method on all those instances as well.If the
stateargument isnull, take no action and return.- Specified by:
restoreStatein interfaceStateHolder- Overrides:
restoreStatein classUIComponentBase- Parameters:
context- the Faces context.state- the state.
-
saveState
public Object saveState(FacesContext context)
Description copied from interface:StateHolderGets the state of the instance as a
SerializableObject.If the class that implements this interface has references to instances that implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.saveState(jakarta.faces.context.FacesContext)method on all those instances as well. This method must not save the state of children and facets. That is done via theStateManagerThis method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);componentshould be the same as before executing it.The return from this method must be
Serializable- Specified by:
saveStatein interfaceStateHolder- Overrides:
saveStatein classUIComponentBase- Parameters:
context- the Faces context.- Returns:
- the saved state.
-
getDataModel
protected DataModel getDataModel()
Return the internal
DataModelobject representing the data objects that we will iterate over in this component's rendering.If the model has been cached by a previous call to
setDataModel(jakarta.faces.model.DataModel), return it. Otherwise callgetValue(). If the result is null, create an emptyListDataModeland return it. If the result is an instance ofDataModel, return it. Otherwise, adapt the result as described ingetValue()and return it.- Returns:
- the data model.
-
setDataModel
protected void setDataModel(DataModel dataModel)
Set the internal DataModel. This
UIDatainstance must use the givenDataModelas its internal value representation from now until the next call tosetDataModel. If the givenDataModelisnull, the internalDataModelmust be reset in a manner so that the next call togetDataModel()causes lazy instantion of a newly refreshedDataModel.Subclasses might call this method if they either want to restore the internal
DataModelduring the Restore View phase or if they want to explicitly refresh the currentDataModelfor the Render Response phase.- Parameters:
dataModel- the newDataModelornullto cause the model to be refreshed.
-
-