On Mon, 04 Oct 2010 19:35:38 -0300, Omar Carvajal
<[email protected]> wrote:
Hey all,
Hi!
I am trying to dynamically load a component which must be determined at
run time, I figured I must use a t:delegate to render the component.
On the Java side of things I cannot figure out how to instantiate the
actual component. I saw the @Component annotation with the "type"
parameter but this does not let me dynamically load a component from a
function.
Does anybody have any idea on how to do this?
Declare the components inside a <t:block>. <t:block> are not rendered
unless you pass it to a Delegate or return it to update a Zone. You cannot
instantiate components in Java code, as Tapestry is static structure,
dynamic behavior (including rendering). Take a look at
http://tapestry.apache.org/tapestry5.1/cookbook/switch.html. It shows you
how to render blocks dynamically, but the same approach can be used for
components as well. You'll use @InjectComponent to get access in your Java
code to the component instances declared in templates.
--
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: [email protected]
For additional commands, e-mail: [email protected]