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


Field Summary
static java.lang.String COMPONENT_FAMILY
           
static java.lang.String COMPONENT_TYPE
           
 
Fields inherited from class javax.faces.component.UIComponent
bindings
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
UIData()
          Construct an instance of the UIData.
 
Method Summary
 void broadcast(FacesEvent event)
          Ensure that before the event's listeners are invoked this UIData component's "current row" is set to the row associated with the event.
 void encodeBegin(FacesContext context)
          Perform necessary actions when rendering of this component starts, before delegating to the inherited implementation which calls the associated renderer's encodeBegin method.
 void encodeEnd(FacesContext context)
           
 java.lang.String getClientId(FacesContext context)
          Get a string which can be output to the response which uniquely identifies this UIComponent within the current view.
protected  DataModel getDataModel()
          Return the datamodel for this table, potentially fetching the data from a backing bean via a value-binding if this is the first time this method has been called.
 java.lang.String getFamily()
           
 int getFirst()
          Gets The index of the first row to be displayed, where 0 is the first row.
 UIComponent getFooter()
           
 UIComponent getHeader()
           
 int getRowCount()
           
 java.lang.Object getRowData()
           
 int getRowIndex()
           
 int getRows()
          Gets The number of rows to be displayed.
 java.lang.Object getValue()
          Gets An EL expression that specifies the data model that backs this table.
 java.lang.String getVar()
          Gets Defines the name of the request-scope variable that will hold the current row during iteration.
 boolean invokeOnComponent(FacesContext context, java.lang.String clientId, ContextCallback callback)
          invokeOnComponent must be implemented in UIComponentBase too...
 boolean isRowAvailable()
           
 void processDecodes(FacesContext context)
           
 void processUpdates(FacesContext context)
          This isn't an input component, so just pass on the processUpdates call to child components and facets that might be input components.
 void processValidators(FacesContext context)
           
 void queueEvent(FacesEvent event)
          Modify events queued for any child components so that the UIData state will be correctly configured before the event's listeners are executed.
 void restoreState(FacesContext facesContext, java.lang.Object state)
          Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.
 java.lang.Object saveState(FacesContext facesContext)
          Invoked after the render phase has completed, this method returns an object which can be passed to the restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this object currently has.
protected  void setDataModel(DataModel dataModel)
           
 void setFirst(int first)
          Set the index of the first row to be displayed, where 0 is the first row.
 void setFooter(UIComponent footer)
           
 void setHeader(UIComponent header)
           
 void setRowIndex(int rowIndex)
          Set the current row index that methods like getRowData use.
 void setRows(int rows)
          Set the maximum number of rows displayed in the table.
 void setValue(java.lang.Object value)
           
 void setValueExpression(java.lang.String name, javax.el.ValueExpression binding)
           
 void setVar(java.lang.String var)
          Sets Defines the name of the request-scope variable that will hold the current row during iteration.
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, decode, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_FAMILY

public static final java.lang.String COMPONENT_FAMILY
See Also:
Constant Field Values

COMPONENT_TYPE

public static final java.lang.String COMPONENT_TYPE
See Also:
Constant Field Values
Constructor Detail

UIData

public UIData()
Construct an instance of the UIData.

Method Detail

invokeOnComponent

public boolean invokeOnComponent(FacesContext context,
                                 java.lang.String clientId,
                                 ContextCallback callback)
                          throws FacesException
Description copied from class: UIComponentBase
invokeOnComponent must be implemented in UIComponentBase too...

Overrides:
invokeOnComponent in class UIComponentBase
Parameters:
context - FacesContext for the current request
clientId - the id of the desired UIComponent clazz
callback - Implementation of the ContextCallback to be called
Returns:
has component been found ?
Throws:
FacesException

setFooter

public void setFooter(UIComponent footer)

getFooter

public UIComponent getFooter()

setHeader

public void setHeader(UIComponent header)

getHeader

public UIComponent getHeader()

isRowAvailable

public boolean isRowAvailable()

getRowCount

public int getRowCount()

getRowData

public java.lang.Object getRowData()

getRowIndex

public int getRowIndex()

setRowIndex

public void setRowIndex(int rowIndex)
Set the current row index that methods like getRowData use.

Param rowIndex can be -1, meaning "no row".

Parameters:
rowIndex -

setValueExpression

public void setValueExpression(java.lang.String name,
                               javax.el.ValueExpression binding)
Overrides:
setValueExpression in class UIComponent

getClientId

public java.lang.String getClientId(FacesContext context)
Description copied from class: UIComponentBase
Get a string which can be output to the response which uniquely identifies this UIComponent within the current view.

The component should have an id attribute already assigned to it; however if the id property is currently null then a unique id is generated and set for this component. This only happens when components are programmatically created without ids, as components created by a ViewHandler should be assigned ids when they are created.

If this component is a descendant of a NamingContainer then the client id is of form "{namingContainerId}:{componentId}". Note that the naming container's id may itself be of compound form if it has an ancestor naming container. Note also that this only applies to naming containers; other UIComponent types in the component's ancestry do not affect the clientId.

Finally the renderer associated with this component is asked to convert the id into a suitable form. This allows escaping of any characters in the clientId which are significant for the markup language generated by that renderer.

Overrides:
getClientId in class UIComponentBase

queueEvent

public void queueEvent(FacesEvent event)
Modify events queued for any child components so that the UIData state will be correctly configured before the event's listeners are executed.

Child components or their renderers may register events against those child components. When the listener for that event is eventually invoked, it may expect the uidata's rowData and rowIndex to be referring to the same object that caused the event to fire.

The original queueEvent call against the child component has been forwarded up the chain of ancestors in the standard way, making it possible here to wrap the event in a new event whose source is this component, not the original one. When the event finally is executed, this component's broadcast method is invoked, which ensures that the UIData is set to be at the correct row before executing the original event.

Overrides:
queueEvent in class UIComponentBase

broadcast

public void broadcast(FacesEvent event)
               throws AbortProcessingException
Ensure that before the event's listeners are invoked this UIData component's "current row" is set to the row associated with the event.

See queueEvent for more details.

Overrides:
broadcast in class UIComponentBase
Parameters:
event - must not be null.
Throws:
AbortProcessingException

encodeBegin

public void encodeBegin(FacesContext context)
                 throws java.io.IOException
Perform necessary actions when rendering of this component starts, before delegating to the inherited implementation which calls the associated renderer's encodeBegin method.

Overrides:
encodeBegin in class UIComponentBase
Throws:
java.io.IOException

encodeEnd

public void encodeEnd(FacesContext context)
               throws java.io.IOException
Overrides:
encodeEnd in class UIComponentBase
Throws:
java.io.IOException
See Also:
UIComponentBase.encodeEnd(javax.faces.context.FacesContext)

processDecodes

public void processDecodes(FacesContext context)
Overrides:
processDecodes in class UIComponentBase

processValidators

public void processValidators(FacesContext context)
Overrides:
processValidators in class UIComponentBase

processUpdates

public void processUpdates(FacesContext context)
Description copied from class: UIComponentBase
This isn't an input component, so just pass on the processUpdates call to child components and facets that might be input components.

Components that were never rendered can't possibly be receiving update data (no corresponding fields were ever put into the response) so if this component is not rendered then this method does not invoke processUpdates on its children.

Overrides:
processUpdates in class UIComponentBase

getDataModel

protected DataModel getDataModel()
Return the datamodel for this table, potentially fetching the data from a backing bean via a value-binding if this is the first time this method has been called.

This is complicated by the fact that this table may be nested within another table. In this case a different datamodel should be fetched for each row. When nested within a parent table, the parent reference won't change but parent.getClientId() will, as the suffix changes depending upon the current row index. A map object on this component is therefore used to cache the datamodel for each row of the table. In the normal case where this table is not nested inside a component that changes its id (like a table does) then this map only ever has one entry.


setDataModel

protected void setDataModel(DataModel dataModel)

setValue

public void setValue(java.lang.Object value)

setRows

public void setRows(int rows)
Set the maximum number of rows displayed in the table.


setFirst

public void setFirst(int first)
Set the index of the first row to be displayed, where 0 is the first row.


getValue

public java.lang.Object getValue()
Gets An EL expression that specifies the data model that backs this table. The value can be of any type. A value of type DataModel is used directly. Array-like parameters of type java.util.List, array of Object, java.sql.ResultSet, or javax.servlet.jsp.jstl.sql.Result are wrapped in a DataModel. Other values are wrapped in a DataModel as a single row.

Returns:
the new value value

getVar

public java.lang.String getVar()
Gets Defines the name of the request-scope variable that will hold the current row during iteration. This value must be a static value.

Returns:
the new var value

setVar

public void setVar(java.lang.String var)
Sets Defines the name of the request-scope variable that will hold the current row during iteration. This value must be a static value.

Parameters:
var - the new var value

getRows

public int getRows()
Gets The number of rows to be displayed. Specify zero for all remaining rows in the table.

Returns:
the new rows value

getFirst

public int getFirst()
Gets The index of the first row to be displayed, where 0 is the first row.

Returns:
the new first value

saveState

public java.lang.Object saveState(FacesContext facesContext)
Description copied from class: UIComponentBase
Invoked after the render phase has completed, this method returns an object which can be passed to the restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this object currently has.

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

restoreState

public void restoreState(FacesContext facesContext,
                         java.lang.Object state)
Description copied from class: UIComponentBase
Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.

Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIComponentBase
state - is an object previously returned by the saveState method of this class.

getFamily

public java.lang.String getFamily()
Specified by:
getFamily in class UIComponent


Copyright © 2009 Apache Software Foundation. All Rights Reserved.