Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Where does that content come from? You inject it into your page.

Code Block
controlstrue
linenumberstrue
<t:zone id="search" t:id="searchZone">
  <t:form t:id="searchForm" zone="searchZone">
    <t:textfield t:id="query" size="20"/>
    <input type="submit" value="Search"/>
  </t:form>
</t:zone>

<t:block id="searchResults">
  <ul>
    <li t:type="loop" source="searchHits" value="searchHit">${searchHit}</li>
  </ul>
</t:block>
Code Block
controlstrue
linenumberstrue
  @Inject
  private Block searchResults;

  Object onSuccessFromSearchForm()
  {
    searchHits = searchService.performSearch(query);

    return searchResults;
  }

...

Instead of returning a Block or a Component, return a multi-zone update:

Code Block
controlstrue
linenumberstrue
  @Inject
  private Block searchResults;

  @Inject
  private Block statusBlock;

  Object onSuccessFromSearchForm()
  {
    searchHits = searchService.performSearch(query);

    message = String.format("Found %,d matching documents", searchHits.size());

    return new MultiZoneUpdate("results", searchResults).add("status", statusBlock);
  }

...

You might start with markup in your template for a component such as a TextField:

Code Block
controlstrue
linenumberstrue
  <t:textfield t:id="firstName"/>

When the component initially renders as part of a full page render, you get a sensible
bit of markup:

Code Block
controlstrue
linenumberstrue
  <input id="firstName" name="firstName" type="text">

But when the form is inside a Zone and rendered as part of a zone update, the ids get weird:

Code Block
controlstrue
linenumberstrue
   <input id="firstName_12a820cc40e" name="firstName" type="text">

...

When the component is rendered as part of an Ajax partial page update, the rules are different. Since Tapestry doesn't know what content has been
rendered onto the page previously, it can't use is its normal tricks to ensure that ids are unique.

...