With a delegate component.
in your template:
<div t:type="loop" t:source="foos" t:value="item" >
<t:delegate to="renderBlock" />
<t:category.preview.render t:previewId="preview.id"/>
</div>
<t:block t:id="compAblock">
<component.A id="item.id" />
</t:block>
<t:block t:id="compBblock">
<component.B id="item.id" />
</t:block>
<t:block t:id="compCblock">
<component.C id="item.id" />
</t:block>
and in your page class:
@InjectComponent
private Block compAblock;
@InjectComponent
private Block compBblock;
@InjectComponent
private Block compCblock;
public Block getRenderBlock()
{
if(item instanceof A)
return compAblock;
if(item instanceof B)
return compBblock;
if(item instanceof C)
return compCblock;
}
Something along those lines. I hope you get the idea, don't take any of
those code snippets as granted :)
Uli
Davor Miku schrieb:
Hi!
Let's say I have:
public interface Foo {
getId();
}
public class A implements Foo {
}
public class B implements Foo {
}
public class C implements Foo {
}
public class Index {
private Map<Float, Foo> foos = new TreeMap<Float, Foo>();
}
Let there be components for classes A,B,C, also
<component.A id="" /> etc.
I want in Index.tml to loop over foos, and based on Foo type to call
appropriate component (A,B or C):
Something like:
<div t:type="loop" t:source="foos" t:value="item" >
/* Here should be something like :
if(item insanceof A)
<component.A id="item.id" />
if(item insanceof B)
<component.B id="item.id" />
if(item insanceof C)
<component.C id="item.id" />
*/
<t:category.preview.render t:previewId="preview.id"/>
</div>
As I know Tapestry If component is checking true/false on property, and
adding that properties to
Foo is not an option.
I hope I'm clear enough.
So, how could I accomplish this?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org