[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: [T5] Choosing components at runtime
From:       Michael Courcy <michael.courcy () gmail ! com>
Date:       2008-01-19 14:23:10
Message-ID: 479207CE.1020301 () gmail ! com
[Download RAW message or body]


John Owen Atala a écrit :
> 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) { ... }
> 
I don't unsderstand the sentence this way, I woud think something like 
that :

<t:MyComponent param1="bla" otherComponent="myOtherComponent" />

well, I may be completly wrong ... I'm gonna try it and comeback to you 
to see if I find something interesting.
> 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: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> > 
> > 
> 
> 


-- 
Michael Courcy
http://courcy.blogspot.com



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic