I don't know enough about tapestry internals to say if this is a good idea, but I've played around with DynamicBlock and your solution looks a lot simpler. At a guess, it looks like your approach is setting up your dynamic component when tapestry is loading the page template. If it's part of tapestry template cache, that means it would only pick the dynamic content the first time the page is loaded and reuse the same component on every subsequent call to the page - unless you're running in dev mode with page caching disabled. But as I said, that's a guess.

If I'm wrong, I want to know how well does it handle things like RenderBody and passing parameters to your component? If it handles those concerns well, I'm tempted to wrap it up into a generic DynamicComponent.

If I'm right, it probably jives with Howard's vision of static structure/dynamic behavior, but may not function in the way you intended.

-Steve

Portuendo Vestado wrote:
Hi all,

I'm trying to find a way to have the Delegator component use some other
component with a template (chosen at runtime) to render output, and the
closest I found was using PageLoader's createImplicitComponent() function.
Is this correct for my intent? Are there more proper means of achieving the
same effect?

Technically I'm not trying to attach an implicit component to the page
dynamically - I simply want to be able to instantiate a regular component
with a template, and delegate rendering to it (or to one of several regular
components, chosen at runtime based on some criteria).
Here's the code:

Home.java
[...]
        @InjectObject("service:tapestry.page.PageLoader")
        public abstract IPageLoader getPageLoader();

        public IRender getDynamicComponent() {
                return getComponent("whatever");
        }

        public void finishLoad(IRequestCycle cycle, IPageLoader loader,
IComponentSpecification specification) {
                super.finishLoad(cycle, loader, specification);

                IComponent iComponent =
getPageLoader().createImplicitComponent(getRequestCycle(), this, "whatever",
"layout/Test", getLocation());
                this.addComponent(iComponent);
        }
[...]


Home.html
[...]
<span jwcid="@Delegator" delegate="ognl:dynamicComponent"/>
[...]

This does delegate and produces output of whatever's in "layout/Test"
component's template.

Is there any downside to this approach (seems kinda hacky)? Or would a more
proper way be to actually implement my own IRender which reads from a
template somehow?


Thanks,
-p


                
_______________________________________________________ Yahoo! Mail - Sempre a melhor opção para você! Experimente já e veja as novidades. http://br.yahoo.com/mailbeta/tudonovo/

---------------------------------------------------------------------
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]

Reply via email to