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]