You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alexander Lamb <al...@rodanotech.ch> on 2007/12/20 11:50:18 UTC

Rendering a component from it's name

Hello,

I would like to render a component that would be chosen from it's name  
(a String).

Something like:

<t:Delegate to="myComponentName" param1="..." param2="..." />

In the enclosing component I would have:

public String getMyComponentName()

Which returns the name of a component in my project. It would be  
instantiated and the parameters (param1, etc...) would be passed to it.

I would allow to build a page dynamically from data found in a  
database for example:

- if it's a string, put the TextField component, if it's a "choice",  
put the Select component, if it's a xyz, put MySpecialComponent.

I thought it would be possible with Delegate, but I am afraid I didn't  
understand well how to achieve this.

Thanks,

Alex

--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch




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


Re: Rendering a component from it's name

Posted by Josh Canfield <jo...@thedailytube.com>.
Hi Alex,

A delegate component is used to render a block component.

I don't believe you are going to be able to find a general way to grab any
component from your project and dynamically stick it in the page. Read
Principle 1 -- Static Structure, Dynamic Behavior on
http://tapestry.formos.com/nightly/tapestry5/ for more information.

I'd suggest building one component that understands what to do with all of
your database types and values and delegates to other components for
rendering. Those components have to be statically defined.

Josh


On Dec 20, 2007 2:50 AM, Alexander Lamb <al...@rodanotech.ch>
wrote:

> Hello,
>
> I would like to render a component that would be chosen from it's name
> (a String).
>
> Something like:
>
> <t:Delegate to="myComponentName" param1="..." param2="..." />
>
> In the enclosing component I would have:
>
> public String getMyComponentName()
>
> Which returns the name of a component in my project. It would be
> instantiated and the parameters (param1, etc...) would be passed to it.
>
> I would allow to build a page dynamically from data found in a
> database for example:
>
> - if it's a string, put the TextField component, if it's a "choice",
> put the Select component, if it's a xyz, put MySpecialComponent.
>
> I thought it would be possible with Delegate, but I am afraid I didn't
> understand well how to achieve this.
>
> Thanks,
>
> Alex
>
> --
> Alexander Lamb
> Founding Associate
> RODANOTECH Sàrl
>
> 4 ch. de la Tour de Champel
> 1206 Geneva
> Switzerland
>
> Tel:  022 347 77 37
> Fax: 022 347 77 38
>
> http://www.rodanotech.ch
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.