On Thu, 05 Jan 2012 23:35:59 -0200, Jochen Frey <joc...@jochenfrey.com> wrote:

I want to be able to pass a component (by name, or by reference) into another component, so that I can decide at runtime what type of component I put into a container component.

Let's say I have a ContainerComponent, and at runtime I want to decide if I render a ContentComponentA, or a ContentComponentB into the container, how do I do that?

I have tried to put variables into the .tml file to determine the type from a variable in the java class like so: <div t:type=${aType}/>, and that does not work.

The structure of Tapestry templates is strictly static, so this is expected.

It can be done with t:if, but that seems very limiting:

<t:if test="ContentComponentA">
        <div t:type="ContentComponentA"/>
</t:if>
<t:if test="ContentComponentB">
        <div t:type="ContentComponentB"/>
</t:if>


It would be nice if it could be done via formal parameters, or programmatically from the Java side, but I haven't been able to figure it out.

What is the recommended way of doing this?

Check this thread: http://tapestry.1045711.n5.nabble.com/T5-Using-the-strategy-pattern-with-components-td2411126.html#a2411129

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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

Reply via email to