You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Boris Horvat <ho...@gmail.com> on 2013/12/01 23:52:40 UTC

Passing blocks as component parameters

Is there any way to pass a block as a parameter and then to render it?

I have checked a tree component and I have seen it renders it manually. Is
there any way to achieve this by simply passing few parameters around?

Cheers

-- 
Sincerely
*Boris Horvat*

Re: Passing blocks as component parameters

Posted by Boris Horvat <ho...@gmail.com>.
Ah...so simple and somehow I never though of it :)

Thanks, I will try it out shortly

Cheers


On Mon, Dec 2, 2013 at 8:38 PM, Lance Java <la...@googlemail.com>wrote:

> Yup... <t:delegate to="myBlock" />
>
>
> On 2 December 2013 19:36, Boris Horvat <ho...@gmail.com> wrote:
>
> > Let me try to be a bit more specific
> >
> > I want to have a component that I will initialize like this
> >
> > <myComponent myblock="myblock">
> >
> > <t:block id="myblock">asdasd</t:block>
> >
> > and then in the MyComponent.tml I have something like
> >
> > -------------------------------------------
> >
> > <html>
> >
> > <div>sometext</div>
> >
> > <!-- render my parameter here -->
> >
> > </html>
> >
> > ---------------------------------------
> >
> > So if I add
> >
> > @Parameter
> > Block myblock
> >
> > into a MyComponent.java how can I render it?
> >
> > Is this that you were thinking by delegate? I just pass this parameter to
> > the delegate? (I will try this hope it works :))
> >
> >
> > On Mon, Dec 2, 2013 at 9:50 AM, Lance Java <lance.java@googlemail.com
> > >wrote:
> >
> > > As Kristian has said, this can normally be managed with block &
> delegate.
> > >
> > > Another way is to declare (or TypeCoerce) your block as a
> RenderCommand.
> > > You can return a RenderCommand from any render phase method.
> > >
> > > A RenderCommand can delegate to other RenderCommands. Note that
> rendering
> > > mimics tail recursion and can be hard to get your head around :)
> > >
> > >  On 2 Dec 2013 06:25, "Kristian Marinkovic" <
> > kristian.marinkovic@gmail.com
> > > >
> > > wrote:
> > >
> > > > Yes it is possible. Usually you use a Delegate component to render a
> > > Block.
> > > >
> > > > Cheers
> > > > Kris
> > > > Am 01.12.2013 23:53 schrieb "Boris Horvat" <horvat.z.boris@gmail.com
> >:
> > > >
> > > > > Is there any way to pass a block as a parameter and then to render
> > it?
> > > > >
> > > > > I have checked a tree component and I have seen it renders it
> > manually.
> > > > Is
> > > > > there any way to achieve this by simply passing few parameters
> > around?
> > > > >
> > > > > Cheers
> > > > >
> > > > > --
> > > > > Sincerely
> > > > > *Boris Horvat*
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Passing blocks as component parameters

Posted by Lance Java <la...@googlemail.com>.
Yup... <t:delegate to="myBlock" />


On 2 December 2013 19:36, Boris Horvat <ho...@gmail.com> wrote:

> Let me try to be a bit more specific
>
> I want to have a component that I will initialize like this
>
> <myComponent myblock="myblock">
>
> <t:block id="myblock">asdasd</t:block>
>
> and then in the MyComponent.tml I have something like
>
> -------------------------------------------
>
> <html>
>
> <div>sometext</div>
>
> <!-- render my parameter here -->
>
> </html>
>
> ---------------------------------------
>
> So if I add
>
> @Parameter
> Block myblock
>
> into a MyComponent.java how can I render it?
>
> Is this that you were thinking by delegate? I just pass this parameter to
> the delegate? (I will try this hope it works :))
>
>
> On Mon, Dec 2, 2013 at 9:50 AM, Lance Java <lance.java@googlemail.com
> >wrote:
>
> > As Kristian has said, this can normally be managed with block & delegate.
> >
> > Another way is to declare (or TypeCoerce) your block as a RenderCommand.
> > You can return a RenderCommand from any render phase method.
> >
> > A RenderCommand can delegate to other RenderCommands. Note that rendering
> > mimics tail recursion and can be hard to get your head around :)
> >
> >  On 2 Dec 2013 06:25, "Kristian Marinkovic" <
> kristian.marinkovic@gmail.com
> > >
> > wrote:
> >
> > > Yes it is possible. Usually you use a Delegate component to render a
> > Block.
> > >
> > > Cheers
> > > Kris
> > > Am 01.12.2013 23:53 schrieb "Boris Horvat" <ho...@gmail.com>:
> > >
> > > > Is there any way to pass a block as a parameter and then to render
> it?
> > > >
> > > > I have checked a tree component and I have seen it renders it
> manually.
> > > Is
> > > > there any way to achieve this by simply passing few parameters
> around?
> > > >
> > > > Cheers
> > > >
> > > > --
> > > > Sincerely
> > > > *Boris Horvat*
> > > >
> > >
> >
>
>
>
> --
> Sincerely
> *Boris Horvat*
>

Re: Passing blocks as component parameters

Posted by Boris Horvat <ho...@gmail.com>.
Let me try to be a bit more specific

I want to have a component that I will initialize like this

<myComponent myblock="myblock">

<t:block id="myblock">asdasd</t:block>

and then in the MyComponent.tml I have something like

-------------------------------------------

<html>

<div>sometext</div>

<!-- render my parameter here -->

</html>

---------------------------------------

So if I add

@Parameter
Block myblock

into a MyComponent.java how can I render it?

Is this that you were thinking by delegate? I just pass this parameter to
the delegate? (I will try this hope it works :))


On Mon, Dec 2, 2013 at 9:50 AM, Lance Java <la...@googlemail.com>wrote:

> As Kristian has said, this can normally be managed with block & delegate.
>
> Another way is to declare (or TypeCoerce) your block as a RenderCommand.
> You can return a RenderCommand from any render phase method.
>
> A RenderCommand can delegate to other RenderCommands. Note that rendering
> mimics tail recursion and can be hard to get your head around :)
>
>  On 2 Dec 2013 06:25, "Kristian Marinkovic" <kristian.marinkovic@gmail.com
> >
> wrote:
>
> > Yes it is possible. Usually you use a Delegate component to render a
> Block.
> >
> > Cheers
> > Kris
> > Am 01.12.2013 23:53 schrieb "Boris Horvat" <ho...@gmail.com>:
> >
> > > Is there any way to pass a block as a parameter and then to render it?
> > >
> > > I have checked a tree component and I have seen it renders it manually.
> > Is
> > > there any way to achieve this by simply passing few parameters around?
> > >
> > > Cheers
> > >
> > > --
> > > Sincerely
> > > *Boris Horvat*
> > >
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Passing blocks as component parameters

Posted by Lance Java <la...@googlemail.com>.
As Kristian has said, this can normally be managed with block & delegate.

Another way is to declare (or TypeCoerce) your block as a RenderCommand.
You can return a RenderCommand from any render phase method.

A RenderCommand can delegate to other RenderCommands. Note that rendering
mimics tail recursion and can be hard to get your head around :)

 On 2 Dec 2013 06:25, "Kristian Marinkovic" <kr...@gmail.com>
wrote:

> Yes it is possible. Usually you use a Delegate component to render a Block.
>
> Cheers
> Kris
> Am 01.12.2013 23:53 schrieb "Boris Horvat" <ho...@gmail.com>:
>
> > Is there any way to pass a block as a parameter and then to render it?
> >
> > I have checked a tree component and I have seen it renders it manually.
> Is
> > there any way to achieve this by simply passing few parameters around?
> >
> > Cheers
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>

Re: Passing blocks as component parameters

Posted by Kristian Marinkovic <kr...@gmail.com>.
Yes it is possible. Usually you use a Delegate component to render a Block.

Cheers
Kris
Am 01.12.2013 23:53 schrieb "Boris Horvat" <ho...@gmail.com>:

> Is there any way to pass a block as a parameter and then to render it?
>
> I have checked a tree component and I have seen it renders it manually. Is
> there any way to achieve this by simply passing few parameters around?
>
> Cheers
>
> --
> Sincerely
> *Boris Horvat*
>