Class Hierarchy All Classes All Fields and Methods
Class javax.faces.component.UIData
java.lang.Object javax.faces.component.UIComponent javax.faces.component.UIComponentBase javax.faces.component.UIDatapublic class UIData
implements NamingContainer
extends UIComponentBase
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 ValueBinding). 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 javax.faces.Table. This value can be changed by calling the setRendererType() method.
Field Index Field Description COMPONENT_FAMILY The standard component family for this component. COMPONENT_TYPE The standard component type for this component.
Constructor Index Constructor Description UIData() Create a new UIData instance with default property values.
Method Index Method Description void broadcast(FacesEvent) Override the default broadcast processing to unwrap any wrapped FacesEvent and reset the current row index, before the event is actually broadcast. void encodeBegin(FacesContext) 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. String getClientId(FacesContext) Return a client identifier for this component that includes the current value of the rowIndex property, if it is not set to -1. String getFamily() int getFirst() Return the zero-relative row number of the first row to be displayed. UIComponent getFooter() Return the footer facet of this component (if any). UIComponent getHeader() Return the header facet of this component (if any). 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. 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. Object getValue() Return the value of the UIData. String getVar() Return the request-scope attribute under which the data object for the current row will be exposed when iterating. boolean isRowAvailable() Return a flag indicating whether there is rowData available at the current rowIndex. void processDecodes(FacesContext) Override the default processDecodes processing to perform the following steps. void processUpdates(FacesContext) Override the default processUpdates processing to perform the following steps. void processValidators(FacesContext) Override the default processValidators processing to perform the following steps. void queueEvent(FacesEvent) Override the default queueEvent processing to wrap any queued events in a wrapper so that we can reset the current row index in broadcast(). void restoreState(FacesContext, Object) Object saveState(FacesContext) void setFirst(int) Set the zero-relative row number of the first row to be displayed. void setFooter(UIComponent) Set the footer facet of this component. void setHeader(UIComponent) Set the header facet of this component. void setRowIndex(int) 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) Set the number of rows to be displayed, or zero for all remaining rows in the table. void setValue(Object) Set the value of the UIData. void setValueBinding(String, ValueBinding) Set the ValueBinding used to calculate the value for the specified attribute or property name, if any. void setVar(String) Set the request-scope attribute under which the data object for the current row wil be exposed when iterating.
Fields
COMPONENT_FAMILY
public static final java.lang.String COMPONENT_FAMILY
The standard component family for this component.
COMPONENT_TYPE
public static final java.lang.String COMPONENT_TYPE
The standard component type for this component.
Constructors
UIData
public UIData()
Create a new UIData instance with default property values.
Methods
broadcast
public void broadcast(FacesEvent event) throws AbortProcessingException
Override the default broadcast 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.
- Parameters
- event - The FacesEvent to be broadcast
- Throws
- AbortProcessingException Signal the JavaServer Faces implementation that no further processing on the current event should be performed
- Throws
- IllegalArgumentException if the implementation class of this FacesEvent is not supported by this component
- Throws
- NullPointerException if event is null
- Overrides
- broadcast in class UIComponentBase
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.
- Parameters
- context - FacesContext for the current request
- Throws
- IOException if an input/output error occurs while rendering
- Throws
- NullPointerException if context is null
- Overrides
- encodeBegin in class UIComponentBase
getClientId
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).
- Throws
- NullPointerException if context is null
- Overrides
- getClientId in class UIComponentBase
getFamily
public String getFamily()
getFirst
public int getFirst()
Return the zero-relative row number of the first row to be displayed.
getFooter
public UIComponent getFooter()
Return the footer facet of this component (if any). A convenience method for getFacet("footer").
getHeader
public UIComponent getHeader()
Return the header facet of this component (if any). A convenience method for getFacet("header").
getRowCount
public int getRowCount()
Return the number of rows in the underlying data model. If the number of available rows is unknown, return -1.
- 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.
- Throws
- FacesException if an error occurs getting the row data
- Throws
- IllegalArgumentException 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.
- Throws
- FacesException if an error occurs getting the row index
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.
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 a DataModel. UIData will automatically adapt the following types:
- Arrays
- java.util.List
- java.sql.ResultSet
- javax.servlet.jsp.jstl.sql.Result
All other types will be adapted using the ScalarDataModel class, which will treat the object as a single row of data.
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.
isRowAvailable
public boolean isRowAvailable()
Return a flag indicating whether there is rowData available at the current rowIndex. If no wrappedData is available, return false.
- Throws
- FacesException if an error occurs getting the row availability
processDecodes
public void processDecodes(FacesContext context)
Override the default processDecodes processing to perform the following steps.
- If the rendered property of this UIComponent is false, skip further processing.
- Set the current rowIndex to -1.
- Call the processDecodes() method of all facets of this UIData, in the order determined by a call to getFacets().keySet().iterator().
- Call the processDecodes() method of all facets of the UIColumn children of this UIData.
- Iterate over the set of rows that were included when this component was rendered (i.e. those defined by the first and rows properties), performing the following processing for each row:
- Set the current rowIndex to the appropriate value for this row.
- If isRowAvailable() returns true, iterate over the children components of each UIColumn child of this UIData component, calling the processDecodes() method for each such child.
- Set the current rowIndex to -1.
- Call the decode() method of this component.
- If a RuntimeException is thrown during decode processing, call renderResponse and re-throw the exception.
- Parameters
- context - FacesContext for the current request
- Throws
- NullPointerException if context is null
- Overrides
- processDecodes in class UIComponentBase
processUpdates
public void processUpdates(FacesContext context)
Override the default processUpdates processing to perform the following steps.
- If the rendered property of this UIComponent is false, skip further processing.
- Set the current rowIndex to -1.
- Call the processUpdates() method of all facets of this UIData, in the order determined by a call to getFacets().keySet().iterator().
- Call the processUpdates() method of all facets of the UIColumn children of this UIData.
- Iterate over the set of rows that were included when this component was rendered (i.e. those defined by the first and rows properties), performing the following processing for each row:
- Set the current rowIndex to the appropriate value for this row.
- If isRowAvailable() returns true, iterate over the children components of each UIColumn child of this UIData component, calling the processUpdates() method for each such child.
- Set the current rowIndex to -1.
- Parameters
- context - FacesContext for the current request
- Throws
- NullPointerException if context is null
- Overrides
- processUpdates in class UIComponentBase
processValidators
public void processValidators(FacesContext context)
Override the default processValidators processing to perform the following steps.
- If the rendered property of this UIComponent is false, skip further processing.
- Set the current rowIndex to -1.
- Call the processValidators() method of all facets of this UIData, in the order determined by a call to getFacets().keySet().iterator().
- Call the processValidators() method of all facets of the UIColumn children of this UIData.
- Iterate over the set of rows that were included when this component was rendered (i.e. those defined by the first and rows properties), performing the following processing for each row:
- Set the current rowIndex to the appropriate value for this row.
- If isRowAvailable() returns true, iterate over the children components of each UIColumn child of this UIData component, calling the processValidators() method for each such child.
- Set the current rowIndex to -1.
- Parameters
- context - FacesContext for the current request
- Throws
- NullPointerException if context is null
- Overrides
- processValidators in class UIComponentBase
queueEvent
public void queueEvent(FacesEvent event)
Override the default queueEvent processing to wrap any queued events in a wrapper so that we can reset the current row index in broadcast().
- Parameters
- event - FacesEvent to be queued
- Throws
- IllegalStateException if this component is not a descendant of a UIViewRoot
- Throws
- NullPointerException if event is null
- Overrides
- queueEvent in class UIComponentBase
restoreState
public void restoreState(FacesContext context, Object state)
saveState
public Object saveState(FacesContext context)
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 if first is negative
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 if footer is null
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 if header is null
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 the getRowData() method.
- Save current state information for all descendant components (as described below).
- Store the new row index, and pass it on to the DataModel associated with this UIData instance.
- If the new rowIndex value is -1:
- If the var property is not null, remove the corresponding request scope attribute (if any).
- Reset the state information for all descendant components (as described below).
- If the new rowIndex value is not -1:
- If the 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.
- Reset the state information for all descendant components (as described below).
To save current state information for all descendant components, UIData must maintain per-row information for each descendant as follows:
- If the descendant is an instance of EditableValueHolder, save the state of its localValue property.
- If the descendant is an instance of EditableValueHolder, save the state of the localValueSet property.
- If the descendant is an instance of EditableValueHolder, save the state of the valid property.
- If the descendant is an instance of 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:
- If the descendant is an instance of EditableValueHolder, restore the value property.
- If the descendant is an instance of EditableValueHolder, restore the state of the localValueSet property.
- If the descendant is an instance of EditableValueHolder, restore the state of the valid property.
- If the descendant is an instance of EditableValueHolder, restore the state of the submittedValue property.
- Parameters
- rowIndex - The new row index value, or -1 for no associated row
- Throws
- FacesException if an error occurs setting the row index
- Throws
- IllegalArgumentException if rowIndex is less than -1
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 if rows is negative
setValue
public void setValue(Object value)
Set the value of the UIData. This value must either be be of type DataModel, or a type that can be adapted into a DataModel.
- Parameters
- value - the new value
setValueBinding
public void setValueBinding(String name, ValueBinding binding)
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.
- Parameters
- 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
- Throws
- IllegalArgumentException if name is one of id, parent, var, or rowIndex
- Throws
- NullPointerException if name is null
- Overrides
- setValueBinding in class UIComponentBase
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
Class Hierarchy All Classes All Fields and Methods