Class UIData

    • Field Detail

      • COMPONENT_TYPE

        public static final java.lang.String COMPONENT_TYPE

        The standard component type for this component.

        See Also:
        Constant Field Values
      • COMPONENT_FAMILY

        public static final java.lang.String COMPONENT_FAMILY

        The standard component family for this component.

        See Also:
        Constant Field Values
    • Constructor Detail

      • UIData

        public UIData​()

        Create a new UIData instance with default property values.

    • Method Detail

      • getFamily

        public java.lang.String getFamily​()
        Description copied from class: UIComponent

        Return the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the rendererType property, may be used to select the appropriate Renderer for this component instance. Note this method should NOT return null

        Specified by:
        getFamily in class UIComponent
        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:
        java.lang.IllegalArgumentException - if first is 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:
        java.lang.NullPointerException - if footer is null
      • 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:
        java.lang.NullPointerException - if header is null
      • isRowAvailable

        public boolean isRowAvailable​()

        Return a flag indicating whether there is rowData available at the current rowIndex. If no wrappedData is available, return false.

        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 java.lang.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 data
        java.lang.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.

        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 the getRowData() method.

        To support transient state among descendents, please consult the specification for setRowStatePreserved(boolean), which details the requirements for setRowIndex() when the rowStatePreserved JavaBeans property is set to true.

        • 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
        java.lang.IllegalArgumentException - if rowIndex is 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:
        java.lang.IllegalArgumentException - if rows is negative
      • getVar

        public java.lang.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​(java.lang.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 rowStatePreserved JavaBeans property. See setRowStatePreserved(boolean).

        Returns:
        the value of the rowStatePreserved.
        Since:
        2.1
      • getValue

        public java.lang.Object getValue​()

        Return the value of the UIData. This value must either be of type DataModel, or a type that can be adapted into a DataModel. UIData will automatically adapt the following types:

        • java.util.List
        • Arrays
        • java.sql.ResultSet
        • javax.servlet.jsp.jstl.sql.Result
        • java.util.Collection
        • java.lang.Iterable
        • java.util.Map
        • Types for which a suitable DataModel has been registered via FacesDataModel

        All other types will be adapted using the ScalarDataModel class, which will treat the object as a single row of data.

        Returns:
        the object for the value.
      • setValue

        public void setValue​(java.lang.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​(java.lang.String name,
                                    ValueBinding binding)

        If "name" is something other than "value", "var", or "rowIndex", rely on the superclass conversion from ValueBinding to ValueExpression.

        Overrides:
        setValueBinding in class UIComponentBase
        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:
        java.lang.IllegalArgumentException - if name is one of id, parent, var, or rowIndex
        java.lang.NullPointerException - if name is null
      • setValueExpression

        public void setValueExpression​(java.lang.String name,
                                       ValueExpression binding)

        Set the ValueExpression used to calculate the value for the specified attribute or property name, if any. In addition, if a ValueExpression is set for the value property, remove any synthesized DataModel for the data previously bound to this component.

        Overrides:
        setValueExpression in class UIComponent
        Parameters:
        name - Name of the attribute or property for which to set a ValueExpression
        binding - The ValueExpression to set, or null to remove any currently set ValueExpression
        Throws:
        java.lang.IllegalArgumentException - if name is one of id, parent, var, or rowIndex
        java.lang.NullPointerException - if name is null
        Since:
        1.2
      • getClientId

        public java.lang.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).

        Overrides:
        getClientId in class UIComponentBase
        Parameters:
        context - The FacesContext for the current request
        Returns:
        the client id.
        Throws:
        java.lang.NullPointerException - if context is null
      • invokeOnComponent

        public boolean invokeOnComponent​(FacesContext context,
                                         java.lang.String clientId,
                                         ContextCallback callback)
                                  throws FacesException

        Override behavior from UIComponentBase.invokeOnComponent(javax.faces.context.FacesContext, java.lang.String, javax.faces.component.ContextCallback) to provide special care for positioning the data properly before finding the component and invoking the callback on it. If the argument clientId is equal to this.getClientId() simply invoke the contextCallback, passing the context argument and this as arguments, and return true. If the argument clientId is not equal to this.getClientId(), inspect each of the facet children of this UIData instance and for each one, compare its clientId with the argument clientId. If there is a match, invoke the contextCallback, passing the context argument and this as arguments, and return true. Otherwise, attempt to extract a rowIndex from the clientId. For example, if the argument clientId was form:data:3:customerHeader the rowIndex would be 3. Let this value be called newIndex. 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 true if setting the rowIndex of this instance to be equal to newIndex causes this instance to return false from isRowAvailable().

        Overrides:
        invokeOnComponent in class UIComponentBase
        Parameters:
        context - the FacesContext for the current request
        clientId - the client identifier of the component to be passed to the argument callback.
        callback - an implementation of the Callback interface.
        Returns:
        true if the a component with the given clientId is found, the callback method was successfully invoked passing that component as an argument, and no Exception was thrown. Returns false if no component with the given clientId is found.
        Throws:
        java.lang.NullPointerException - if any of the arguments are null
        FacesException - if the argument Callback throws an Exception, it is wrapped in a FacesException and re-thrown. Also throws FacesException if any exception is thrown when deriving the rowIndex from the argument clientId.
        Since:
        1.2
      • encodeBegin

        public void encodeBegin​(FacesContext context)
                         throws java.io.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:
        encodeBegin in class UIComponentBase
        Parameters:
        context - FacesContext for the current request
        Throws:
        java.io.IOException - if an input/output error occurs while rendering
        java.lang.NullPointerException - if context is null
      • processDecodes

        public void processDecodes​(FacesContext context)

        Override the default UIComponentBase.processDecodes(javax.faces.context.FacesContext) 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 FacesContext.renderResponse() and re-throw the exception.
        Overrides:
        processDecodes in class UIComponentBase
        Parameters:
        context - FacesContext for the current request
        Throws:
        java.lang.NullPointerException - if context is null
      • processValidators

        public void processValidators​(FacesContext context)

        Override the default UIComponentBase.processValidators(javax.faces.context.FacesContext) 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.
        Overrides:
        processValidators in class UIComponentBase
        Parameters:
        context - FacesContext for the current request
        Throws:
        java.lang.NullPointerException - if context is null
        See Also:
        PreValidateEvent, PostValidateEvent
      • processUpdates

        public void processUpdates​(FacesContext context)

        Override the default UIComponentBase.processUpdates(javax.faces.context.FacesContext) 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.
        Overrides:
        processUpdates in class UIComponentBase
        Parameters:
        context - FacesContext for the current request
        Throws:
        java.lang.NullPointerException - if context is null
      • createUniqueId

        public java.lang.String createUniqueId​(FacesContext context,
                                               java.lang.String seed)
        Description copied from interface: UniqueIdVendor

        Generate 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:
        createUniqueId in interface UniqueIdVendor
        Parameters:
        context - FacesContext
        seed - 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
Throws:
java.lang.NullPointerException - if any of the parameters are null.
See Also:
VisitContext.invokeVisitCallback()