In a page containing elements generated by a component placed under a
For-Loop component I want to be able to update a single such
component/element using the very nifty
"DojoAjaxResponseBuilder.updateComponent()" feature.
In summary I want to have a DirectLink for each row in a table. The
listener method for this DirectLink will update data, the row should be
updated via the updateComponents attribute of DirectLink.
But... how do I address components generated (and thus named) by a
For-loop?
updateComponents="therow" will work for first row
updateComponents="therow_2" does not work at all (sends updates to the
Insert and DirectLink components in stead!
updateComponents="ognl:'therow_' + theIndex" has the same behaviour. .
Hopefully this small example illustrates my issue: one column for data
one for the async DirectLink to listener "aListener". This code works
for the _first_ row but not the other two.
*The html*
<div jwcid="@Shell" title="Test">
<div jwcid="@Body" class="templatewide">
<table border="1" cellpadding="5">
<span jwcid="@For" source="ognl:rows" value="ognl:row"
index="ognl:theIndex">
<tr jwcid="[EMAIL PROTECTED]">
<td>
<span jwcid="@Insert" value="ognl:row"> </span>
</td>
<td>
<a jwcid="@DirectLink"
listener="listener:aListener"
async="true"
parameters="ognl:{theIndex}"
updateComponents="rowid">
Update this row!
</a>
</td>
</tr>
</span>
</table>
</div>
</div>
*The Page Class*
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageEvent;
import dk.atira.tapestry.AbstractBasePage;
public abstract class NumericPage extends AbstractBasePage {
@Persist
public abstract String[] getRows();
public abstract void setRows(String[] rows);
public abstract String getRow();
public abstract int getTheIndex();
@Override
public void pageBeginRender(PageEvent e)
{
if (getRows() == null){
setRows(new String[] {"foo", "bar", "baz"});
}
}
public void aListener(IRequestCycle cycle, int idx)
{
getRows()[idx] = "" + (int)(Math.random()*10000);
}
}
/thanks
kim
--
Tlf. +45 7214 6793 · [EMAIL PROTECTED] · MSN: [EMAIL PROTECTED]
Atira A/S · Niels Jernes Vej 10 · 9220 Aalborg SØ · www.atira.dk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]