You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Omar Carvajal <ta...@carvajalonline.com> on 2010/10/05 00:35:38 UTC

Dynamically loading a component

Hey all,

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?

Thanks,

Omar

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


Re: Dynamically loading a component

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
hi omar, 

this is not as horrible as it sounds ... testing gets a lot easier

i have a fairly big T5 application with many modules. within this 
application i have many master - detail views where the detail view 
depends on the type of object within the master list and those types can 
be deployed as needed. ie. if i also deploy my order module my master view 
might show some order entry and if i dont deploy it it wont show up. if i 
click on this entry i want to be directed to a order specific page that is 
defined in another (web) module. therefore i created a service that 
contains a contribution of pages to the specific detail view which is used 
to render / create the appropriate links. 

i also have a BlockService (...Registry) where i can contribute blocks 
that should be reused in multiple pages and modules. 

so you always know in advance what you are gonna render. even the possible 
combinations.

for more details take a look at the BeanEditor implementation.

g,
kris




Von:    Omar Carvajal <ta...@carvajalonline.com>
An:     Tapestry users <us...@tapestry.apache.org>
Datum:  05.10.2010 06:19
Betreff:        Re: Dynamically loading a component



This is horrible news since I have no way of knowing the components that 
needs to be called at design time (other wise I would use a <t:block>).

There is no magic that can be done to achieve this at all? Even if I have 
to use the internal services.

Thanks for your quick response.

Omar

On Oct 4, 2010, at 18:41, "Thiago H. de Paula Figueiredo" 
<th...@gmail.com> wrote:

> On Mon, 04 Oct 2010 19:35:38 -0300, Omar Carvajal 
<ta...@carvajalonline.com> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

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



Re: Dynamically loading a component

Posted by Omar Carvajal <ta...@carvajalonline.com>.
This is horrible news since I have no way of knowing the components that needs to be called at design time (other wise I would use a <t:block>).

There is no magic that can be done to achieve this at all? Even if I have to use the internal services.

Thanks for your quick response.

Omar

On Oct 4, 2010, at 18:41, "Thiago H. de Paula Figueiredo" <th...@gmail.com> wrote:

> On Mon, 04 Oct 2010 19:35:38 -0300, Omar Carvajal <ta...@carvajalonline.com> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

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


Re: Dynamically loading a component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 04 Oct 2010 19:35:38 -0300, Omar Carvajal  
<ta...@carvajalonline.com> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org