You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jesse Merriman <je...@gmail.com> on 2007/10/30 17:33:44 UTC

Ajax loop problem

Hi,

I'm having a problem updating a single item within a For loop.

Home.html:
  <div jwcid="@For" source="ognl:testList" value="ognl:testListItem">
    <table jwcid="wrapper@Any">
      <tr>
        <th><a jwcid="@DirectLink"
listener="listener:updateTestListItem" parameters="ognl:testListItem"
updateComponents="wrapper" href="#">Click!</a></th>
      </tr>

      <tr><td><span jwcid="@Insert"
value="ognl:testListItem">TEST</span></td></tr>
    </table>
  </div>

Home.java:
  public abstract String[] getTestList();
  public abstract void setTestList(String[] list);
  public abstract String getTestListItem();
  public abstract void setTestListItem(String item);
  public void updateTestListItem(String item) {
      setTestListItem(item + " CHANGED!");
  }
  public void pageBeginRender(PageEvent event) {
      setTestList(new String[] { "a", "b", "c", "d" });
  }

When the page first loads, everything looks fine (4 tables, with ids
wrapper, wrapper_0, wrapper_1, and wrapper_2, containing a, b, c, and
d). When I click one of the links, I get an ajax-response back like:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
<!ENTITY nbsp '&#160;'>
]>
<ajax-response><response id="wrapper" type="element"><table id="wrapper">
    <tr>
      <th><a id="DirectLink"
href="/j2ee/TestTapApp/app?component=%24DirectLink&amp;page=Home
&amp;service=direct&amp;sp=Sa&amp;updateParts=wrapper" onclick="return
tapestry.linkOnClick(this.href
,'DirectLink', false)">Click!</a></th>
    </tr>
    <tr><td>a</td></tr>
  </table></response></ajax-response>

The text has not been updated to "a CHANGED!". What am I doing wrong?
I'm using Tapestry 4.1.3.

Thanks,
Jesse Merriman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org