hi,

Maybay this will help. I solved that this way:
- I implemented a special delegate component which has all possible
components injected via @Component
- beginRender returns one of the injected components depending on business
logic/database
- Check the .tml-template for the delegate component below, everything is
wrapped inside a t:block to prevent rendering

This way my whole page is rendered right from the database.
regards
c)hri


e.g.

<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";
title="literal:change-this">
<t:block> 

        <t:renderer.ContainerRenderer />
        <t:renderer.HtmlRenderer />
        <t:renderer.TextRenderer />
        <t:renderer.RichTextRenderer /> 
        <t:renderer.ImageRenderer />    

</t:block>

<t:body />

</t:container>




John Owen Atala wrote:
> 
> But how do you make inject works? Do you have a template with every
> component? I don't care if a i must inject every component, but i don't
> wanna create a usefull template with every component too... How do you do
> that?
> Because if a try to inject a component that doesn't exist on template that
> doesn't work to me...
> 
> 
> Daniel Jue wrote:
>> 
>> Seems like it's back to the static structure, dynamic content (the
>> mantra of Tapestry).   So yes, one way people are using is to have all
>> the possible components injected in the parent (page/component) and
>> then the desired component is chosen later using logic you code.
>> I have one page that returns up to 15 components.  About 10 of those
>> components can return possibly one of 3 or 4 related components.
>> I haven't explored other ways of doing it.
>> 
>> 
>> This kind of constraint does do one thing for you: it forces you to
>> think about whether components can be refactored more than they are,
>> so that content changes can have the dramatic differences you want.
>> 
>> On Jan 18, 2008 3:12 PM, John Owen Atala <[EMAIL PROTECTED]> wrote:
>>>
>>> Thanks, that should be usefull, but doesn't help on the issue that to
>>> get an
>>> instance of a component it must be injected somewhere, and that
>>> somewhere's
>>> template must have every component that eventually you will use (because
>>> I
>>> can't inject a component in a class whose template doesn't have it), so
>>> it
>>> will always load every posible component...
>>>
>>> And this is one main problem: i wanna use an injected component that
>>> it's
>>> not on any template on a explicit way. Is there any way to get an
>>> instance
>>> of a component that is not present on any template?
>>>
>>> By the way, there says:
>>> "The component may have been injected via the Component annotation, or
>>> may
>>> have been passed to the as a parameter".
>>> I don't know how to pass a Component as a parameter in a phase render
>>> method, I tried:
>>>
>>> Object beginRender(MyComponent myComponent) { ... }
>>>
>>> but myComponent variable is always null there...
>>>
>>> What do you think?
>>>
>>> Regards,
>>>
>>> John
>>>
>>>
>>>
>>> Michael Courcy wrote:
>>> >
>>> > Taken from
>>> >
>>> http://tapestry.apache.org/tapestry5/tapestry-core/guide/rendering.html
>>> >
>>> >
>>> >     Rendering Components
>>> >
>>> > Instead of returning true or false, a render phase method may return a
>>> > component. The component may have been injected via the Component
>>> >
>>> <http://tapestry.apache.org/tapestry5/tapestry-core/guide/.../apidocs/org/apache/tapestry/annotations/Component.html>
>>> > annotation, or may have been passed to the as a parameter.
>>> >
>>> > In any case, returning a component will queue that component to be
>>> > rendered *before* the active component continues rendering.
>>> >
>>> > The component to render may even be from a completely different page
>>> of
>>> > the application.
>>> >
>>> > Recursive rendering of components is not allowed.
>>> >
>>> > This technique allows the rendering of Tapestry pages to be /highly/
>>> > dynamic.
>>> >
>>> > Returning a component instance does *not* short circuit method
>>> > invocation, the way returning a boolean would. It is possible that
>>> > multiple methods may return components (this is not advised --
>>> insanity
>>> > may ensue).
>>> >
>>> >
>>> >
>>> > johnowenatala a écrit :
>>> >> Hi, i have a place in a page where i wanna put a component, but which
>>> >> component is desided in runtime (can be from configuration or from
>>> >> request
>>> >> parameters).
>>> >> I tried to do this by putting a delegate component, but i couldn't
>>> inject
>>> >> in
>>> >> runtime an unknowed component in compilation time.
>>> >> What do you think i can do? Is this possible?
>>> >>
>>> >
>>> >
>>> > --
>>> > Michael Courcy
>>> > http://courcy.blogspot.com
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> > For additional commands, e-mail: [EMAIL PROTECTED]
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-T5--Choosing-components-at-runtime-tp14933806p14957788.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-T5--Choosing-components-at-runtime-tp14933806p14971920.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to