UIData (Java EE 5)

Java EE API


javax.faces.component Class UIData

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIData
All Implemented Interfaces:
NamingContainer, StateHolder
Direct Known Subclasses:
HtmlDataTable

public class UIData
extends UIComponentBase
implements NamingContainer

Implements: NamingContainer
Extended by: HtmlDataTable

UIData 是支持将数据绑定到由 DataModel 实例表示的数据对象 Collection 的 UIComponent,该实例是此组件本身的当前值(通常通过 ValueExpression 建立)。在对数据模型的数据行进行迭代处理的过程中,当前行的对象作为 var 属性指定的键下的请求属性公开。

只有类型为 UIColumn 的子组件应该由与此组件关联的 renderer 处理。

默认情况下,rendererType 属性被设置为 javax.faces.Table。可以调用 setRendererType() 方法更改此值。

英文文档:

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 javax.faces.Table. This value can be changed by calling the setRendererType() method.


Field Summary
static String
static String
 
Fields inherited from class javax.faces.component.UIComponent
 
Fields inherited from interface javax.faces.component.NamingContainer
 
Constructor Summary
 
Method Summary
 void
 void
 String
protected  DataModel
 String
 int
 UIComponent
 UIComponent
 int
 Object
 int
 int
 Object
 String
 boolean
 boolean
 void
 void
 void
 void
 void
 Object
protected  void
 void
 void
 void
 void
 void
 void
 void
 void
 void
 
Methods inherited from class javax.faces.component.UIComponentBase
 
Methods inherited from class javax.faces.component.UIComponent
 
Methods inherited from class java.lang.Object
 

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

public UIData()

使用默认属性值创建新的 UIData 实例。

英文文档:

UIData

public UIData()

Create a new UIData instance with default property values.

Method Detail

public String getFamily()
英文文档:

getFamily

public 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.

Specified by:
getFamily in class UIComponent

public int getFirst()

返回要显示的第一行的相对于 0 的行号。

英文文档:

getFirst

public int getFirst()

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


public void setFirst(int first)

设置要显示的第一行的相对于 0 的行号。

first 新的第一行行号
ThrowsIllegalArgumentException: 如果 first 为负
英文文档:

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

public UIComponent getFooter()

返回此组件的脚注 facet(如果有)。getFacet("footer") 的便捷方法。

英文文档:

getFooter

public UIComponent getFooter()

Return the footer facet of this component (if any). A convenience method for getFacet("footer").


public void setFooter(UIComponent footer)

设置此组件的脚注 facet。getFacets().put("footer", footer) 的便捷方法。

footer 新的脚注 facet
ThrowsNullPointerException: 如果 footernull
英文文档:

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

public UIComponent getHeader()

返回此组件的头 facet(如果有)。getFacet("header") 的便捷方法。

英文文档:

getHeader

public UIComponent getHeader()

Return the header facet of this component (if any). A convenience method for getFacet("header").


public void setHeader(UIComponent header)

设置此组件的头 facet。getFacets().put("header", header) 的便捷方法。

header 新的头 facet
ThrowsNullPointerException: 如果 headernull
英文文档:

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

public boolean isRowAvailable()

返回一个指示当前 rowIndex 是否有可用的 rowData 的标志。如果没有任何 wrappedData 可用,则返回 false

ThrowsFacesException: 如果检测行可用性时发生错误
英文文档:

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

public int getRowCount()

返回底层数据模型中的行数。如果可用行数未知,则返回 -1。

ThrowsFacesException: 如果获取行数时发生错误
英文文档:

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

public Object getRowData()

返回表示当前选定行索引的数据的数据对象(如果有)。

ThrowsFacesException: 如果获取行数据时发生错误
ThrowsIllegalArgumentException: 如果当前指定行索引处的行数据目前可用
英文文档:

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
IllegalArgumentException - if now row data is available at the currently specified row index

public int getRowIndex()

返回当前选定行相对于 0 的索引。如果我们当前没有位于行上,则返回 -1。没有为值绑定表达式启用此属性。

ThrowsFacesException: 如果获取行索引时发生错误
英文文档:

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

public void setRowIndex(int rowIndex)

通过实现下列算法设置当前行相对于 0 的索引,或者设置为 -1 指示当前没有选定任何行。可以将行索引设置为某个值,在该值处底层数据 Collection 不包含任何行数据。因此,调用者可以使用 isRowAvailable() 方法检测是否可以通过 getRowData() 方法获得行数据。

  • 保存所有后代组件的当前状态信息(如下所述)。
  • 存储新的行索引,并将其传递给与此 UIData 实例关联的 DataModel
  • 如果新的 rowIndex 值为 -1:
    • 如果 var 属性不为 null,则移除相应的请求范围属性(如果有)。
    • 重置所有后代组件的状态信息(如下所述)。
  • 如果新的 rowIndex 值不为 -1:
    • 如果 var 属性不为 null,则调用 getRowData(),并将得到的数据对象作为其键为 var 属性值的请求范围属性公开。
    • 重置所有后代组件的状态信息(如下所述)。

要保存所有后代组件的当前状态信息,UIData 必须维护每个后代的每行信息,如下所示:

  • 如果后代是 EditableValueHolder 的实例,则保存其 localValue 属性的状态。
  • 如果后代是 EditableValueHolder 的实例,则保存 localValueSet 属性的状态。
  • 如果后代是 EditableValueHolder 的实例,则保存 valid 属性的状态。
  • 如果后代是 EditableValueHolder 的实例,则保存 submittedValue 属性的状态。

要恢复所有后代组件的当前状态信息,UIData 必须引用它以前为当前 rowIndex 存储的信息,并为每个后代调用设置方法,如下所示:

  • 如果后代是 EditableValueHolder 的实例,则恢复 value 属性。
  • 如果后代是 EditableValueHolder 的实例,则恢复 localValueSet 属性的状态。
  • 如果后代是 EditableValueHolder 的实例,则恢复 valid 属性的状态。
  • 如果后代是 EditableValueHolder 的实例,则恢复 submittedValue 属性的状态。
英文文档:

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
IllegalArgumentException - if rowIndex is less than -1

public int getRows()

返回要显示的行数,或为表中所有其余行返回 0。此属性的默认值为 0。

英文文档:

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.


public void setRows(int rows)

设置要显示的行数,或为表中所有其余行设置为 0。

rows 新的行数
ThrowsIllegalArgumentException: 如果 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 - if rows is negative

public String getVar()

返回请求范围属性,在迭代时,将在此属性下公开当前行的数据对象。没有为值绑定表达式启用此属性。

英文文档:

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.


public void setVar(String var)

设置请求范围属性,在迭代时,将在此属性下公开当前行的数据对象。

var 新请求范围属性名称
英文文档:

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

public Object saveState(FacesContext context)
英文文档:

saveState

public Object saveState(FacesContext context)
Description copied from interface: StateHolder

Gets the state of the instance as a Serializable Object.

If the class that implements this interface has references to instances that implement StateHolder (such as a UIComponent with event handlers, validators, etc.) this method must call the StateHolder.saveState(javax.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 the StateManager

This method must not alter the state of the implementing object. In other words, after executing this code:

 Object state = component.saveState(facesContext);
 

component should be the same as before executing it.

The return from this method must be Serializable

Specified by:
saveState in interface StateHolder
Overrides:
saveState in class UIComponentBase

public void restoreState(FacesContext context, Object state)
英文文档:

restoreState

public void restoreState(FacesContext context,
                         Object state)
Description copied from interface: StateHolder

Perform 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 UIComponent with event handlers, validators, etc.) this method must call the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object) method on all those instances as well.

Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIComponentBase

public Object getValue()

返回 UIData 的值。此值必须为 DataModel 类型,或者可以适配到 DataModel 中的类型。UIData 将自动适配以下类型:

  • 数组
  • java.util.List
  • java.sql.ResultSet
  • javax.servlet.jsp.jstl.sql.Result

所有其他类型将使用 ScalarDataModel 类适配,该类将对象视作单个数据行。

英文文档:

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.


public void setValue(Object value)

设置 UIData 的值。此值必须为 DataModel 类型,或者可以适配到 DataModel 中的类型。

value 新值
英文文档:

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

public void setValueBinding(String name, ValueBinding binding)

如果 "name" 为 "value"、"var" 或 "rowIndex" 之外的项目,则依赖超类将 ValueBinding 转换为 ValueExpression

name 将为其设置 ValueBinding 的属性的名称
binding 要设置的 ValueBinding,或为 null 以移除任何当前设置的 ValueBinding
ThrowsIllegalArgumentException: 如果 nameidparentvarrowIndex 之一
ThrowsNullPointerException: 如果 namenull
deprecated 此方法已由 #setValueExpression(java.lang.String, javax.el.ValueExpression) 替代。
英文文档:

setValueBinding

public void setValueBinding(String name,
                            ValueBinding binding)
Deprecated. This has been replaced by setValueExpression(java.lang.String, javax.el.ValueExpression).

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:
IllegalArgumentException - if name is one of id, parent, var, or rowIndex
NullPointerException - if name is null

public void setValueExpression(String name, ValueExpression binding)

设置用于计算指定属性名称值的 ValueExpression(如果有)。此外,如果为 value 属性设置了 ValueExpression,则移除以前绑定到此组件的数据的任何合成 DataModel

name 要为其设置 ValueExpression 的属性的名称
binding 要设置的 ValueExpression,或为 null 以移除任何当前设置的 ValueExpression
ThrowsIllegalArgumentException: 如果 nameidparentvarrowIndex 之一
ThrowsNullPointerException: 如果 namenull
since1.2
英文文档:

setValueExpression

public void setValueExpression(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:
IllegalArgumentException - if name is one of id, parent, var, or rowIndex
NullPointerException - if name is null
Since:
1.2

public String getClientId(FacesContext context)

如果 rowIndex 属性的当前值未设置为 -1,则返回包含其当前值的此组件的客户端标识符。这意味着对 getClientId() 的多次调用可能会返回不同的结果,但这会确保该子组件本身能够生成特定于行的客户端标识符(因为 UIDataNamingContainer)。

ThrowsNullPointerException: 如果 contextnull
英文文档:

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).

Overrides:
getClientId in class UIComponentBase
Parameters:
context - The FacesContext for the current request
Throws:
NullPointerException - if context is null

public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback) throws FacesException

重写 UIComponentBase#invokeOnComponent 中的行为,以便在找到组件并调用其上的回调之前,对正确定位数据予以特别关注。如果参数 clientId 等于 this.getClientId(),则只需调用 contextCallback 同时将 context 参数和 this 作为参数传递即可,然后返回 true。否则,尝试从 clientId 中提取 rowIndex。例如,如果参数 clientIdform:data:3:customerHeader,则 rowIndex 将为 3。使此值称为 newIndex。在所有情况下,都必须保存此实例的当前 rowIndex 并在返回之前将其恢复,无论搜索结果如何或是否在此过程中抛出任何异常。

如果将此实例的 rowIndex 设置为等于 newIndex 导致此实例从 #isRowAvailable 返回 false,则此方法的实现绝不会返回 true

since1.2
ThrowsNullPointerException: NullPointerException NullPointerException 如果任何参数为 null
ThrowsFacesException: NullPointerException 如果参数 Callback 抛出 Exception,则将在 FacesException 中包装它并将其重新抛出。 如果在从参数 clientId 派生 rowIndex 时有任何异常抛出,则还抛出 FacesException
英文文档:

invokeOnComponent

public boolean invokeOnComponent(FacesContext context,
                                 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. 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:
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

public void queueEvent(FacesEvent event)

重写默认的 UIComponentBase#queueEvent 处理以在包装器中包装任何排队事件,以便可以在 broadcast() 中重置当前的行索引。

event 要排队的 FacesEvent
ThrowsIllegalStateException: 如果此组件不是 UIViewRoot 的后代
ThrowsNullPointerException: 如果 eventnull
英文文档:

queueEvent

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().

Overrides:
queueEvent in class UIComponentBase
Parameters:
event - FacesEvent to be queued
Throws:
IllegalStateException - if this component is not a descendant of a UIViewRoot
NullPointerException - if event is null

public void broadcast(FacesEvent event) throws AbortProcessingException

重写默认的 UIComponentBase#broadcast 处理以便在实际广播事件之前,对任何已包装的 FacesEvent 解包,并重置当前行索引。对于未包装的事件(在 queueEvent() 中),将执行默认处理。

event 要广播的 FacesEvent
ThrowsAbortProcessingException: 通知 JavaServer Face 实现不应该继续处理当前事件
ThrowsIllegalArgumentException: 如果此组件不支持此 FacesEvent 的实现类
ThrowsNullPointerException: 如果 eventnull
英文文档:

broadcast

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.

Overrides:
broadcast in class UIComponentBase
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
IllegalArgumentException - if the implementation class of this FacesEvent is not supported by this component
NullPointerException - if event is null

public void encodeBegin(FacesContext context) throws java.io.IOException

除默认行为外,确保子输入组件的任何已保存的每行状态都被丢弃,除非需要它来呈现当前带有错误的页面。

context 当前请求的 FacesContext
Throwsjava.io.IOException: 如果呈现期间发生输入/输出错误
ThrowsNullPointerException: 如果 contextnull

英文文档:

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:
encodeBegin in class UIComponentBase
Parameters:
context - FacesContext for the current request
Throws:
IOException - if an input/output error occurs while rendering
NullPointerException - if context is null

public void processDecodes(FacesContext context)

重写默认的 UIComponentBase#processDecodes 处理以执行下列步骤。

  • 如果此 UIComponentrendered 属性为 false,则跳过进一步的处理。
  • 将当前 rowIndex 设置为 -1。
  • 按照调用 getFacets().keySet().iterator() 所确定的顺序,调用此 UIData 所有 facet 的 processDecodes() 方法。
  • 调用此 UIDataUIColumn 子组件的所有 facet 的 processDecodes() 方法。
  • 迭代呈现此组件时包含的行集合(即通过 firstrows 属性定义的那些行),对每个行执行以下处理:
    • 将当前 rowIndex 设置为此行的相应值。
    • 如果 isRowAvailable() 返回 true,则在此 UIData 组件的每个 UIColumn 子组件的子组件上迭代,同时为每个此类子组件调用 processDecodes() 方法。
  • 将当前 rowIndex 设置为 -1。
  • 调用此组件的 decode() 方法。
  • 如果在解码处理期间抛出 RuntimeException,则调用 FacesContext#renderResponse 并重新抛出该异常。
context 当前请求的 FacesContext
ThrowsNullPointerException: 如果 contextnull
英文文档:

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:
NullPointerException - if context is null

public void processValidators(FacesContext context)

重写默认的 UIComponentBase#processValidators 处理以执行下列步骤。

  • 如果此 UIComponentrendered 属性为 false,则跳过进一步的处理。
  • 将当前 rowIndex 设置为 -1。
  • 按照调用 getFacets().keySet().iterator() 所确定的顺序,调用此 UIData 所有 facet 的 processValidators() 方法。
  • 调用此 UIDataUIColumn 子组件的所有 facet 的 processValidators() 方法。
  • 迭代呈现此组件时包含的行集合(即通过 firstrows 属性定义的那些行),对每个行执行以下处理:
    • 将当前 rowIndex 设置为此行的相应值。
    • 如果 isRowAvailable() 返回 true,则在此 UIData 组件的每个 UIColumn 子组件的子组件上迭代,同时为每个此类子组件调用 processValidators() 方法。
  • 将当前 rowIndex 设置为 -1。
context 当前请求的 FacesContext
ThrowsNullPointerException: 如果 contextnull
英文文档:

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:
NullPointerException - if context is null

public void processUpdates(FacesContext context)

重写默认的 UIComponentBase#processUpdates 处理以执行下列步骤。

  • 如果此 UIComponentrendered 属性为 false,则跳过进一步的处理。
  • 将当前 rowIndex 设置为 -1。
  • 按照调用 getFacets().keySet().iterator() 所确定的顺序,调用此 UIData 所有 facet 的 processUpdates() 方法。
  • 调用此 UIDataUIColumn 子组件的所有 facet 的 processUpdates() 方法。
  • 迭代呈现此组件时包含的行集合(即通过 firstrows 属性定义的那些行),对每个行执行以下处理:
    • 将当前 rowIndex 设置为此行的相应值。
    • 如果 isRowAvailable() 返回 true,则在此 UIData 组件的每个 UIColumn 子组件的子组件上迭代,同时为每个此类子组件调用 processUpdates() 方法。
  • 将当前 rowIndex 设置为 -1。
context 当前请求的 FacesContext
ThrowsNullPointerException: 如果 contextnull
英文文档:

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:
NullPointerException - if context is null

protected DataModel getDataModel()

返回表示将在此组件的呈现中迭代的数据对象的内部 DataModel 对象。

如果通过以前调用 #setDataModel 缓存过该模型,则将其返回。否则调用 #getValue。如果结果为 null,则创建空的 ListDataModel 并将其返回。如果结果是 DataModel 的实例,则将其返回。否则,适配 #getValue 中所述的结果,并将其返回。

英文文档:

getDataModel

protected DataModel getDataModel()

Return the internal DataModel object 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(javax.faces.model.DataModel), return it. Otherwise call getValue(). If the result is null, create an empty ListDataModel and return it. If the result is an instance of DataModel, return it. Otherwise, adapt the result as described in getValue() and return it.


protected void setDataModel(DataModel dataModel)

设置内部 DataModel。从现在开始,此 UIData 实例必须使用给定的 DataModel 作为其内部值表示形式,直到下次调用 setDataModel。如果给定的 DataModelnull,则必须以某种方式重置内部 DataModel,这样下次调用 #getDataModel 会导致新刷新的 DataModel 的延迟实例化。

如果子类要在恢复视图 阶段恢复内部 DataModel,或如果这些子类要在呈现响应 阶段显式刷新当前的 DataModel,则子类可能会调用此方法。

dataModel 新的 DataModelnull 以使模型被刷新。
英文文档:

setDataModel

protected void setDataModel(DataModel dataModel)

Set the internal DataModel. This UIData instance must use the given DataModel as its internal value representation from now until the next call to setDataModel. If the given DataModel is null, the internal DataModel must be reset in a manner so that the next call to getDataModel() causes lazy instantion of a newly refreshed DataModel.

Subclasses might call this method if they either want to restore the internal DataModel during the Restore View phase or if they want to explicitly refresh the current DataModel for the Render Response phase.

Parameters:
dataModel - the new DataModel or null to cause the model to be refreshed.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!