You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kartweel <rh...@exemail.com.au> on 2009/08/11 09:02:18 UTC

Dynamically selecting a component to render output

Ok... This has probably been dealt with, but I can't find an answer or must
be searching the wrong thing...

I need a component to be dynamically selected at runtime rather than being
static in the template and using an <t:if> (or delegate and blocks, etc) to
show it. Any pointers to be able to do this?

The functionality i am trying to get:

I have a page which lists a whole bunch of rows of data. When the user
clicks a row I want a section to open underneath which displays an editor
for that row. Now the editor displayed will be dependent on the type of data
in that row (each editor will have a different class and template, I can
make all the "editors" inherit from a base class if needed). My ideal lookup
mechanism for what editor would be to load it using the class name which
matches data in the row so I can simply add new editors by just adding a new
class.

Now I've thought about doing this with the block and delegate method, but
then I need to edit a master template every time I add a class. Other
thoughts were using an iframe and loading it as a page rather than embedding
a component, but I like the component idea better coz it gives me more
flexibility.

Ok Thanks everyone!
-- 
View this message in context: http://www.nabble.com/Dynamically-selecting-a-component-to-render-output-tp24912684p24912684.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Dynamically selecting a component to render output

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 11 Aug 2009 04:11:59 -0300, Ulrich Stärk <ul...@spielviel.de>  
escreveu:

> Block and delegate are indeed meant for those situations. I'd take that  
> approach.

Me too. There's an example here:  
http://tapestry.apache.org/tapestry5.1/cookbook/switch.html.
Another option is using block and delegate, but using blocks from other  
pages. That's what BeanEditor, BeanEditForm and Grid do. Take a look at  
their sources fro inspiration.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Dynamically selecting a component to render output

Posted by Ulrich Stärk <ul...@spielviel.de>.
Block and delegate are indeed meant for those situations. I'd take that approach.

Uli

On 11.08.2009 09:02 schrieb kartweel:
> Ok... This has probably been dealt with, but I can't find an answer or must
> be searching the wrong thing...
> 
> I need a component to be dynamically selected at runtime rather than being
> static in the template and using an <t:if> (or delegate and blocks, etc) to
> show it. Any pointers to be able to do this?
> 
> The functionality i am trying to get:
> 
> I have a page which lists a whole bunch of rows of data. When the user
> clicks a row I want a section to open underneath which displays an editor
> for that row. Now the editor displayed will be dependent on the type of data
> in that row (each editor will have a different class and template, I can
> make all the "editors" inherit from a base class if needed). My ideal lookup
> mechanism for what editor would be to load it using the class name which
> matches data in the row so I can simply add new editors by just adding a new
> class.
> 
> Now I've thought about doing this with the block and delegate method, but
> then I need to edit a master template every time I add a class. Other
> thoughts were using an iframe and loading it as a page rather than embedding
> a component, but I like the component idea better coz it gives me more
> flexibility.
> 
> Ok Thanks everyone!

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