The idea is that you have somewhere in your application a Block that supplies the components and markup that you need.
You delegate to a method that @Injects the ComponentSource and, using rules that you devise, obtains a page instance and then obtains a block from that page instance and returns it. That block will be rendered in place of the Delegate component, even though it is on a different page entirely ... a block acts like a closure on its containing page. This is a very powerful concept, the highest order of Tapestry skill is when you "grok the block". On Fri, Feb 6, 2009 at 7:07 AM, Dave Greggory <davegregg...@yahoo.com> wrote: > > I am using the delegate, but it's getting the "to-component" of delegate that > I need to do at runtime. I cannot already have the "to-component" declared > with @Inject because I do not know what it is till runtime. > > > ----- Original Message ---- > From: Thiago H. de Paula Figueiredo <thiag...@gmail.com> > To: Tapestry users <users@tapestry.apache.org> > Sent: Friday, February 6, 2009 5:57:53 AM > Subject: Re: [T5] Dynamically getting a component from IoC > > On Thu, Feb 5, 2009 at 10:33 PM, Dave Greggory <davegregg...@yahoo.com> wrote: >> Is it possible dynamically (programmatically) request a component from >> tapestry's IoC (without using @Inject or passing component via parameter)? >> >> I have this MyComponentInterface and a whole bunch of components that >> implement it (ie. MyComponent1, MyComponent2, etc). I do not know until >> runtime if any of these components will be rendered or exactly which >> implementation will be used. On top of that, MyComponent1 may be rendered >> multiple times (each time with a different configuration) and I do not know >> the number of times till runtime either. >> >> So, is it possible to grab a component from IoC at runtime? > > AFAIK, no. Components are handled outside Tapestry-IoC. I suggest you > to use blocks and the Delegate component to accomplish what you want. > There's a simple example at > http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html. > > -- > Thiago > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org