Hi All,

I have a component Foo in a loop on my TestPage.  Foo has a block on it
which Foo's template renders and which Foo's page class also picks up and
adds to a list of blocks on the TestPage's surrounding Layout component.
Layout loops over these blocks and renders them just before the </body>
tag.   Problem is that the layout-rendered blocks are all the same -- namely
the last block added to Layout by Foo.  What am I doing wrong?  Code and and
rendering results:

Foo.java
------------
@Property (write = false)
private int _ref;

@Inject
private ComponentResources _resources;

void beginRender () {
    _ref = (new Object()).hashCode(); // For a pretty reliably random int.
    Layout layout = (Layout)
_resources.getPage().getComponentResources().getEmbeddedComponent( "layout"
);
    layout.addPostWrapperBlock( _resources.findBlock( "tester" ));
}

Foo.tml
----------
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:block t:id="tester">
        <p>Ref: ${ref}</p>
    </t:block>
    <t:delegate to="block:tester" />
</t:container>

TestPage.tml
------------------
<t:layout t:id="layout" xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:loop source="0..2"><t:test.foo /></t:loop>
</t:layout>

Layout.tml (partial)
-------------------------
...
<t:loop source="postWrapperBlocks" value="var:pwb"><t:delegate to="var:pwb"
/></t:loop>
</body>
</html>

When Foo renders in TestPage's template, no problem:
Ref: 16084489
Ref: 736239
Ref: 9163575

But the rendering at the bottom of Layout is
Ref: 9163575
Ref: 9163575
Ref: 9163575

-- 
Bill @ PeoplePad

Reply via email to