com.primix.tapestry.components
Class Foreach
java.lang.Object
|
+--com.primix.tapestry.AbstractComponent
|
+--com.primix.tapestry.components.Foreach
- All Implemented Interfaces:
- IComponent, IRender
- public class Foreach
- extends AbstractComponent
Repeatedly renders its wrapped contents while iterating through
a list of values.
Parameter |
Type |
Read / Write |
Required |
Default |
Description |
source |
Iterator
Collection
java.lang.Object[]
|
R
| no |
|
The source of objects to be iterated, which may be a Collection,
an Iterator or an array of Objects. If unbound, or the binding
is null, or bound to an unusable value (one not in the list),
then no iteration takes place. |
value |
java.lang.Object |
W |
no |
|
Used to update the current value on each iteration.
Alternate, wrapped components may access the value via
the value property . |
index |
int |
W |
no |
|
Used to store the index of the current value within the stream of
elements provided by the source parameter. The index parameter is
explicitly updated before the value parameter.
|
element |
String |
R |
no |
|
If specified, then the component acts like an Any , emitting an open
and close tag before and after each iteration.
Most often, the element is "tr" when the Foreach is part of an HTML
table. Any informal parameters
are applied to the tag. If no element is specified, informal parameters
are ignored.
|
Informal parameters are allowed. A body is allowed (and expected).
- Version:
- $Id: Foreach.java,v 1.14 2001/08/24 21:38:47 hship Exp $
- Author:
- Howard Ship
Methods inherited from class com.primix.tapestry.AbstractComponent |
addAsset, addComponent, addWrapped, cleanupAfterRender, cleanupComponent, finishLoad, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getPage, getSpecification, prepareForRender, renderWrapped, reset, setBinding, setContainer, setId, setPage, setSpecification, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Foreach
public Foreach()
getSourceBinding
public IBinding getSourceBinding()
getIndexBinding
public IBinding getIndexBinding()
setIndexBinding
public void setIndexBinding(IBinding value)
setElementBinding
public void setElementBinding(IBinding value)
- Since:
- 1.0.4
getElementBinding
public IBinding getElementBinding()
- Since:
- 1.0.4
getSourceData
protected java.util.Iterator getSourceData()
throws RequestCycleException
- Gets the source binding and returns an
Iterator
representing
the values identified by the source. Returns an empty Iterator
if the binding, or the binding value, is null.
Invokes Tapestry.coerceToIterator(Object)
to perform
the actual conversion.
getValueBinding
public IBinding getValueBinding()
render
public void render(IResponseWriter writer,
IRequestCycle cycle)
throws RequestCycleException
- Gets the source binding and iterates through
its values. For each, it updates the value binding and render's its wrapped elements.
setSourceBinding
public void setSourceBinding(IBinding value)
setValueBinding
public void setValueBinding(IBinding value)
getValue
public java.lang.Object getValue()
- Returns the most recent value extracted from the source parameter.
- Throws:
RenderOnlyPropertyException
- is the Foreach is not currently rendering.