in tapestry-framework/src/org/apache/tapestry/form/ListEdit.java [46:120]
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
Iterator i = null;
IForm form = getForm(cycle);
boolean cycleRewinding = cycle.isRewinding();
// If the cycle is rewinding, but not this particular form,
// then do nothing (don't even render the body).
if (cycleRewinding && !form.isRewinding())
return;
String name = form.getElementId(this);
if (!cycleRewinding)
{
i = Tapestry.coerceToIterator(getSourceBinding().getObject());
}
else
{
RequestContext context = cycle.getRequestContext();
String[] submittedValues = context.getParameters(name);
i = Tapestry.coerceToIterator(submittedValues);
}
// If the source (when rendering), or the submitted values (on submit)
// are null, then skip the remainder (nothing to update, nothing to
// render).
if (i == null)
return;
int index = 0;
IBinding indexBinding = getIndexBinding();
IBinding valueBinding = getValueBinding();
IActionListener listener = getListener();
String element = getElement();
while (i.hasNext())
{
Object value = null;
if (indexBinding != null)
indexBinding.setInt(index++);
if (cycleRewinding)
value = convertValue((String) i.next());
else
{
value = i.next();
writeValue(form, name, value);
}
valueBinding.setObject(value);
if (listener != null)
listener.actionTriggered(this, cycle);
if (element != null)
{
writer.begin(element);
renderInformalParameters(writer, cycle);
}
renderBody(writer, cycle);
if (element != null)
writer.end();
}
}