|
|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 | ||||||||
javax.faces.component Class UIData
java.lang.Objectjavax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UIData
- 所有已实现的接口:
- NamingContainer, StateHolder
- 直接已知子类:
- HtmlDataTable
public class UIData
- extends UIComponentBase
- implements NamingContainer
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.
| 字段摘要 | |
|---|---|
static String |
COMPONENT_FAMILY
The standard component family for this component. |
static String |
COMPONENT_TYPE
The standard component type for this component. |
| Fields inherited from class javax.faces.component.UIComponent |
|---|
bindings |
| Fields inherited from interface javax.faces.component.NamingContainer |
|---|
SEPARATOR_CHAR |
| 构造器摘要 | |
|---|---|
UIData()
Create a new UIData instance with default property
values. |
|
| 方法摘要 | |
|---|---|
void |
broadcast(FacesEvent event)
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. |
void |
encodeBegin(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. |
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. |
protected DataModel |
getDataModel()
Return the internal DataModel object representing the
data objects that we will iterate over in this component's
rendering. |
String |
getFamily()
Return the identifier of the component family to which this component belongs. |
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 |
invokeOnComponent(FacesContext context,
String clientId,
ContextCallback callback)
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. |
boolean |
isRowAvailable()
Return a flag indicating whether there is rowData
available at the current rowIndex. |
void |
processDecodes(FacesContext context)
Override the default UIComponentBase.processDecodes(javax.faces.context.FacesContext)
processing to perform the following steps. |
void |
processUpdates(FacesContext context)
Override the default UIComponentBase.processUpdates(javax.faces.context.FacesContext)
processing to perform the following steps. |
void |
processValidators(FacesContext context)
Override the default UIComponentBase.processValidators(javax.faces.context.FacesContext)
processing to perform the following steps. |
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(). |
void |
restoreState(FacesContext context,
Object state)
Perform any processing required to restore the state from the entries in the state Object. |
Object |
saveState(FacesContext context)
Gets the state of the instance as a Serializable Object. |
protected void |
setDataModel(DataModel dataModel)
Set the internal DataModel. |
void |
setFirst(int first)
Set the zero-relative row number of the first row to be displayed. |
void |
setFooter(UIComponent footer)
Set the footer facet of this component. |
void |
setHeader(UIComponent header)
Set the header facet of this component. |
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. |
void |
setRows(int rows)
Set the number of rows to be displayed, or zero for all remaining rows in the table. |
void |
setValue(Object value)
Set the value of the UIData. |
void |
setValueBinding(String name,
ValueBinding binding)
Deprecated. This has been replaced by setValueExpression(java.lang.String, javax.el.ValueExpression). |
void |
setValueExpression(String name,
ValueExpression binding)
Set the ValueExpression used to calculate the value for the
specified attribute or property name, if any. |
void |
setVar(String var)
Set the request-scope attribute under which the data object for the current row wil be exposed when iterating. |
| 类方法继承 javax.faces.component.UIComponent |
|---|
encodeAll, getContainerClientId, getValueExpression |
| 类方法继承 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The standard component type for this component.
- 另请参见:
- 常量字段
COMPONENT_FAMILY
public static final String COMPONENT_FAMILY
The standard component family for this component.
- 另请参见:
- 常量字段
| 构造器详细信息 |
|---|
UIData
public UIData()
Create a new
UIDatainstance with default property values.
| 方法详细信息 |
|---|
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
rendererTypeproperty, may be used to select the appropriateRendererfor this component instance.- 规范说明:
getFamilyin classUIComponent
getFirst
public int getFirst()
Return the zero-relative row number of the first row to be displayed.
setFirst
public void setFirst(int first)
Set the zero-relative row number of the first row to be displayed.
- 参数:
first- New first row number- 抛出异常:
IllegalArgumentException- iffirstis negative
getFooter
public UIComponent getFooter()
Return the footer facet of this component (if any). A convenience method for
getFacet("footer").
setFooter
public void setFooter(UIComponent footer)
Set the footer facet of this component. A convenience method for
getFacets().put("footer", footer).- 参数:
footer- the new footer facet- 抛出异常:
NullPointerException- iffooterisnull
getHeader
public UIComponent getHeader()
Return the header facet of this component (if any). A convenience method for
getFacet("header").
setHeader
public void setHeader(UIComponent header)
Set the header facet of this component. A convenience method for
getFacets().put("header", header).- 参数:
header- the new header facet- 抛出异常:
NullPointerException- ifheaderisnull
isRowAvailable
public boolean isRowAvailable()
Return a flag indicating whether there is
rowDataavailable at the currentrowIndex. If nowrappedDatais available, returnfalse.- 抛出异常:
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.
- 抛出异常:
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.
- 抛出异常:
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.
- 抛出异常:
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.
- 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,
UIData must 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,
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 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.
- 参数:
rowIndex- The new row index value, or -1 for no associated row- 抛出异常:
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.
setRows
public void setRows(int rows)
Set the number of rows to be displayed, or zero for all remaining rows in the table.
- 参数:
rows- New number of rows- 抛出异常:
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.
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.
- 参数:
var- The new request-scope attribute name
saveState
public Object saveState(FacesContext context)
- Description copied from interface:
StateHolder Gets 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(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 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- 规范说明:
saveStatein interfaceStateHolder- 重写:
saveStatein classUIComponentBase
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
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)method on all those instances as well.- 规范说明:
restoreStatein interfaceStateHolder- 重写:
restoreStatein classUIComponentBase
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.ResultSetjavax.servlet.jsp.jstl.sql.Result
All other types will be adapted using the
ScalarDataModelclass, which will treat the object as a single row of data.
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.- 参数:
value- the new value
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
ValueBindingtoValueExpression.- 重写:
setValueBindingin classUIComponentBase
- 参数:
name- Name of the attribute or property for which to set aValueBindingbinding- TheValueBindingto set, ornullto remove any currently setValueBinding- 抛出异常:
IllegalArgumentException- ifnameis one ofid,parent,var, orrowIndexNullPointerException- ifnameisnull
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.- 重写:
setValueExpressionin classUIComponent
- 参数:
name- Name of the attribute or property for which to set aValueExpressionbinding- TheValueExpressionto set, ornullto remove any currently setValueExpression- 抛出异常:
IllegalArgumentException- ifnameis one ofid,parent,var, orrowIndexNullPointerException- ifnameisnull- 从以下版本开始:
- 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).- 重写:
getClientIdin classUIComponentBase
- 参数:
context- TheFacesContextfor the current request- 抛出异常:
NullPointerException- ifcontextisnull
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 argumentclientIdis equal tothis.getClientId()simply 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().- 重写:
invokeOnComponentin classUIComponentBase
- 参数:
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.- 返回:
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.- 抛出异常:
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.- 从以下版本开始:
- 1.2
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 inbroadcast().- 重写:
queueEventin classUIComponentBase
- 参数:
event-FacesEventto be queued- 抛出异常:
IllegalStateException- if this component is not a descendant of aUIViewRootNullPointerException- ifeventisnull
broadcast
public void broadcast(FacesEvent event) throws AbortProcessingException
Override the default
UIComponentBase.broadcast(javax.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.- 重写:
broadcastin classUIComponentBase
- 参数:
event- TheFacesEventto be broadcast- 抛出异常:
AbortProcessingException- Signal the JavaServer 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.
- 重写:
encodeBeginin classUIComponentBase
- 参数:
context- FacesContext for the current request- 抛出异常:
IOException- if an input/output error occurs while renderingNullPointerException- ifcontextisnull
processDecodes
public void processDecodes(FacesContext context)
Override the default
UIComponentBase.processDecodes(javax.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.
- If the
- 重写:
processDecodesin classUIComponentBase
- 参数:
context-FacesContextfor the current request- 抛出异常:
NullPointerException- ifcontextisnull
processValidators
public void processValidators(FacesContext context)
Override the default
UIComponentBase.processValidators(javax.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.
- If the
- 重写:
processValidatorsin classUIComponentBase
- 参数:
context-FacesContextfor the current request- 抛出异常:
NullPointerException- ifcontextisnull
processUpdates
public void processUpdates(FacesContext context)
Override the default
UIComponentBase.processUpdates(javax.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.
- If the
- 重写:
processUpdatesin classUIComponentBase
- 参数:
context-FacesContextfor the current request- 抛出异常:
NullPointerException- ifcontextisnull
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(javax.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.
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.- 参数:
dataModel- the newDataModelornullto cause the model to be refreshed.
|
|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 | ||||||||
提交错误或意见
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.
