org.apache.myfaces.trinidad.component
Class UIXIterator

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by org.apache.myfaces.trinidad.component.UIXComponent
          extended by org.apache.myfaces.trinidad.component.UIXComponentBase
              extended by org.apache.myfaces.trinidad.component.UIXCollection
                  extended by org.apache.myfaces.trinidad.component.UIXIterator
All Implemented Interfaces:
javax.faces.component.NamingContainer, javax.faces.component.StateHolder
Direct Known Subclasses:
UIXTable

public class UIXIterator
extends UIXCollection

UIXIterator is a component that performs iteration over its child components. It is similar to UIXTable but has no chrome. Each child is repeatedly stamped as many times as necessary. Iteration is done starting at the index given by the "first" attribute, for as many indices as specified by the "rows" attribute. If "rows" returns 0, then the iteration continues until there are no more elements in the underlying data.

While the <tr:forEach> will be sufficient for most user's needs, it does not work with a JSF DataModel, or CollectionModel. It also cannot be bound to EL expressions that use component-managed EL variables (such as the "var" variable on an <tr:table>), because a forEach tag runs during The <tr:iterator> tag was created to address these issues.

To list all, the benefits of UIXIterator over forEach:

and the negative aspects:

By default, it processes up to 25 rows. Use the rows attribute to alter this behavior.

Events:

Type Phases Description
org.apache.myfaces.trinidad.event.AttributeChangeEvent Invoke Application
Apply Request Values
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing.


Field Summary
static java.lang.String COMPONENT_FAMILY
           
static java.lang.String COMPONENT_TYPE
           
static PropertyKey FIRST_KEY
           
static PropertyKey ROWS_KEY
           
static FacesBean.Type TYPE
           
static PropertyKey VALUE_KEY
           
static PropertyKey VAR_STATUS_KEY
           
 
Fields inherited from class org.apache.myfaces.trinidad.component.UIXCollection
VAR_KEY
 
Fields inherited from class org.apache.myfaces.trinidad.component.UIXComponentBase
BINDING_KEY, ID_KEY, RENDERED_KEY, RENDERER_TYPE_KEY, TRANSIENT_KEY
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
  UIXIterator()
          Construct an instance of the UIXIterator.
protected UIXIterator(java.lang.String rendererType)
          Construct an instance of the UIXIterator.
 
Method Summary
protected  CollectionModel createCollectionModel(CollectionModel current, java.lang.Object value)
          Creates the CollectionModel to use with this component.
protected  java.util.Map<java.lang.String,java.lang.Object> createVarStatusMap()
          Enhances the varStatusMap created by the super class to include: begin - the index of the first row being rendered first - true if the current row is the first row count - indicates which iteration this is.
 void encodeChildren(javax.faces.context.FacesContext context)
          Repeatedly render the children as many times as needed.
protected  FacesBean.Type getBeanType()
           
 java.lang.String getFamily()
           
 int getFirst()
          Gets the index of the first row in the currently range of rows.
 boolean getRendersChildren()
          Override to return true.
 int getRows()
          Gets the maximum number of rows to display in a single range of rows.
 java.lang.Object getValue()
          Gets the data model being used by this component.
 java.lang.String getVarStatus()
          Gets Name of the EL variable used to reference the varStatus information.
protected  void processFacetsAndChildren(javax.faces.context.FacesContext context, javax.faces.event.PhaseId phaseId)
          Process this component's facets and children.
 void setFirst(int first)
          Sets the index of the first row in the currently range of rows.
 void setRows(int rows)
          Sets the maximum number of rows to display in a single range of rows.
 void setValue(java.lang.Object value)
          Sets the data model being used by this component.
 void setVarStatus(java.lang.String varStatus)
          Sets Name of the EL variable used to reference the varStatus information.
 
Methods inherited from class org.apache.myfaces.trinidad.component.UIXCollection
broadcast, clearCurrencyStringCache, decodeChildrenImpl, encodeBegin, encodeEnd, getClientRowKey, getClientRowKeyManager, getCollectionModel, getCollectionModel, getCurrencyString, getLocalClientId, getRowCount, getRowData, getRowData, getRowIndex, getRowKey, getSortCriteria, getStamps, getVar, isRowAvailable, isRowAvailable, isSortable, postRowDataChange, preRowDataChange, processComponent, processDecodes, processSaveState, queueEvent, resetStampState, restoreStampState, restoreState, saveStampState, saveState, setClientRowKey, setCurrencyString, setRowIndex, setRowKey, setSortCriteria, setVar, updateChildrenImpl, validateChildrenImpl
 
Methods inherited from class org.apache.myfaces.trinidad.component.UIXComponentBase
addAttributeChange, addAttributeChangeListener, addFacesListener, broadcastToMethodBinding, createFacesBean, decode, decodeChildren, encodeAll, findComponent, getAttributeChangeListener, getAttributeChangeListeners, getAttributes, getBooleanProperty, getChildCount, getChildren, getClientId, getFacesBean, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacetNames, getFacets, getFacetsAndChildren, getId, getIntProperty, getLifecycleRenderer, getParent, getProperty, getPropertyKey, getRenderer, getRendererType, getValueBinding, isRendered, isTransient, markInitialState, processRestoreState, processUpdates, processValidators, removeAttributeChangeListener, removeFacesListener, setAttributeChangeListener, setBooleanProperty, setId, setIntProperty, setParent, setProperty, setRendered, setRendererType, setTransient, setValueBinding, toString, updateChildren, validateChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final FacesBean.Type TYPE

VAR_STATUS_KEY

public static final PropertyKey VAR_STATUS_KEY

VALUE_KEY

public static final PropertyKey VALUE_KEY

ROWS_KEY

public static final PropertyKey ROWS_KEY

FIRST_KEY

public static final PropertyKey FIRST_KEY

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

UIXIterator

public UIXIterator()
Construct an instance of the UIXIterator.


UIXIterator

protected UIXIterator(java.lang.String rendererType)
Construct an instance of the UIXIterator.

Method Detail

getRendersChildren

public boolean getRendersChildren()
Override to return true.

Overrides:
getRendersChildren in class UIXComponentBase

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context)
                    throws java.io.IOException
Repeatedly render the children as many times as needed.

Overrides:
encodeChildren in class UIXComponentBase
Throws:
java.io.IOException

createVarStatusMap

protected java.util.Map<java.lang.String,java.lang.Object> createVarStatusMap()
Enhances the varStatusMap created by the super class to include:

Overrides:
createVarStatusMap in class UIXCollection

createCollectionModel

protected CollectionModel createCollectionModel(CollectionModel current,
                                                java.lang.Object value)
Description copied from class: UIXCollection
Creates the CollectionModel to use with this component.

Specified by:
createCollectionModel in class UIXCollection
Parameters:
current - the current CollectionModel, or null if there is none.
value - this is the value returned from UIXCollection.getValue()

processFacetsAndChildren

protected void processFacetsAndChildren(javax.faces.context.FacesContext context,
                                        javax.faces.event.PhaseId phaseId)
Description copied from class: UIXCollection
Process this component's facets and children. This method should call UIXCollection.processComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, javax.faces.event.PhaseId) as many times as necessary for each facet and child. UIXCollection.processComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, javax.faces.event.PhaseId) may be called repeatedly for the same child if that child is being stamped.

Specified by:
processFacetsAndChildren in class UIXCollection

getVarStatus

public final java.lang.String getVarStatus()
Gets Name of the EL variable used to reference the varStatus information. Once this component has completed rendering, this variable is removed (or reverted back to its previous value). The VarStatus provides contextual information about the state of the component to EL expressions. For components that iterate, varStatus also provides loop counter information. Please see the this component's documentation for the specific properties on the varStatus. The common properties on varStatus include:

Specified by:
getVarStatus in class UIXCollection
Returns:
the new varStatus value
See Also:
UIXCollection.createVarStatusMap()

setVarStatus

public final void setVarStatus(java.lang.String varStatus)
Sets Name of the EL variable used to reference the varStatus information. Once this component has completed rendering, this variable is removed (or reverted back to its previous value). The VarStatus provides contextual information about the state of the component to EL expressions. For components that iterate, varStatus also provides loop counter information. Please see the this component's documentation for the specific properties on the varStatus. The common properties on varStatus include:

Parameters:
varStatus - the new varStatus value

getValue

public final java.lang.Object getValue()
Gets the data model being used by this component. The specific model class is org.apache.myfaces.trinidad.model.CollectionModel. You may also use other model instances, e.g., java.util.List , array, and javax.faces.model.DataModel. This component will automatically convert the instance into a CollectionModel.

This is a required property on the component.

Specified by:
getValue in class UIXCollection
Returns:
the new value value

setValue

public final void setValue(java.lang.Object value)
Sets the data model being used by this component. The specific model class is org.apache.myfaces.trinidad.model.CollectionModel. You may also use other model instances, e.g., java.util.List , array, and javax.faces.model.DataModel. This component will automatically convert the instance into a CollectionModel.

This is a required property on the component.

Parameters:
value - the new value value

getRows

public final int getRows()
Gets the maximum number of rows to display in a single range of rows. Some ranges might have fewer than the number of rows specified by this attribute (eg: the last range might have an insufficient number of rows). To display all rows at once, set this attribute to 0. The default is 25.

Returns:
the new rows value

setRows

public final void setRows(int rows)
Sets the maximum number of rows to display in a single range of rows. Some ranges might have fewer than the number of rows specified by this attribute (eg: the last range might have an insufficient number of rows). To display all rows at once, set this attribute to 0. The default is 25.

Parameters:
rows - the new rows value

getFirst

public final int getFirst()
Gets the index of the first row in the currently range of rows. This index is zero-based. This attribute is used to control which range of rows to display to the user.

Returns:
the new first value

setFirst

public final void setFirst(int first)
Sets the index of the first row in the currently range of rows. This index is zero-based. This attribute is used to control which range of rows to display to the user.

Parameters:
first - the new first value

getFamily

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

getBeanType

protected FacesBean.Type getBeanType()
Overrides:
getBeanType in class UIXComponentBase


Copyright © 2001-2008 The Apache Software Foundation. All Rights Reserved.