You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Edward Scanzano <es...@yahoo.com> on 2005/05/20 06:50:09 UTC
Dynamic component selection
Hi all,
I have a situtation where I need to include a
component into a page, however, which component it is
will be selected at runtime in the .java file. How do
I do this?
Thanks
E
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Dynamic component selection
Posted by Pablo Ruggia <pr...@gmail.com>.
You can use RenderBlock components. It has a parameter so you can
specify a method to get what block to render.
In your template:
<span ..... jwcid="block1@Block" ......>
your first choice component
</span>
<span ..... jwcid="block2@Block" ......>
the another one
</span>
<span .... jwcid="@RenderBlock" ..... block="ognl:chooseBlock" />
In your Java File:
public Block getChooseBlock(){
if something
return getComponent("block1");
else
return getComponent("block2)";
}
On 5/20/05, Patrick Casey <pa...@adelphia.net> wrote:
>
> Something like this should work I think.
>
>
> public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {
> IComponent comp = null;
> if (choice == foo)
> comp = cycle.getPage().getComponent("foo");
> else if (choice == bar)
> comp = cycle.getPage().getComponent("foo");
>
> if (comp != null)
> comp.render(writer,cycle);
>
> }
> > -----Original Message-----
> > From: Edward Scanzano [mailto:escanzano@yahoo.com]
> > Sent: Thursday, May 19, 2005 9:50 PM
> > To: tapestry-user
> > Subject: Dynamic component selection
> >
> > Hi all,
> >
> > I have a situtation where I need to include a
> > component into a page, however, which component it is
> > will be selected at runtime in the .java file. How do
> > I do this?
> >
> > Thanks
> > E
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Dynamic component selection
Posted by Patrick Casey <pa...@adelphia.net>.
Something like this should work I think.
public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {
IComponent comp = null;
if (choice == foo)
comp = cycle.getPage().getComponent("foo");
else if (choice == bar)
comp = cycle.getPage().getComponent("foo");
if (comp != null)
comp.render(writer,cycle);
}
> -----Original Message-----
> From: Edward Scanzano [mailto:escanzano@yahoo.com]
> Sent: Thursday, May 19, 2005 9:50 PM
> To: tapestry-user
> Subject: Dynamic component selection
>
> Hi all,
>
> I have a situtation where I need to include a
> component into a page, however, which component it is
> will be selected at runtime in the .java file. How do
> I do this?
>
> Thanks
> E
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org