You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mark lilly <mi...@tinorb.com> on 2004/10/08 00:02:50 UTC

Passing Component to Component

HI,
I'm feeling dense, as if i'm so close to figuring this out, but...
I need some help.

I have a border component. Typical. Imagine Header, Left Nav and Body sections.

The Header i can code in the body.html, but i want the Lef Nav to be 
parameterized, so i can create two html pages like this:

pageOne.html
<jwcid="@Border" leftNavComponent="LeftNavCompOne" />

pageTwo.html
<jwcid="@Border" leftNavComponent="LeftNavCompTwo" />

Both LeftNavCompOne and LeftNavCompTwo are components in themselves, but which 
one gets used by the border component gets decided by the page creator, not the 
border creator.

I'm not sure how to pass into a parameter that's a component. Can i??

If someone could show me how, that would rock!!

Thanks,
mark



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Passing Component to Component

Posted by Mind Bridge <mi...@yahoo.com>.
Jamie's suggestion is pretty good. If I may also offer another possibility
as well:


In Border.jwc define the parameter that will accept the component argument:

<parameter name="leftNavComponent" type="org.apache.tapestry.IRender"/>

In Border.html you can render this parameter using the Delegator component:

<span jwcid="@Delegator" delegate="ognl:leftNavComponent"/>

You can then use Border in your pages in the desired way:

<span jwcid="@Border" leftNavComponent="ognl:myComponent">
...
</span>


Another alternative that might be easier in some cases is to use Block and
RenderBlock.

In Border.jwc define the parameter like this:

<parameter name="leftNavComponent"
type="org.apache.tapestry.components.Block"/>

In Border.html use RenderBlock to render the parameter:

<span jwcid="@RenderBlock" block="ognl:leftNavComponent"/>

And do something like this in your pages to use it:

<span jwcid="@Border" leftNavComponent="ognl:components.myLeftNav">
...
</span>

<span jwcid="myLeftNav@Block">
...
</span>


I hope those options help as well.



----- Original Message ----- 
From: "mark lilly" <mi...@tinorb.com>
To: <ta...@jakarta.apache.org>
Sent: Friday, October 08, 2004 1:02 AM
Subject: Passing Component to Component


> HI,
> I'm feeling dense, as if i'm so close to figuring this out, but...
> I need some help.
>
> I have a border component. Typical. Imagine Header, Left Nav and Body
sections.
>
> The Header i can code in the body.html, but i want the Lef Nav to be
> parameterized, so i can create two html pages like this:
>
> pageOne.html
> <jwcid="@Border" leftNavComponent="LeftNavCompOne" />
>
> pageTwo.html
> <jwcid="@Border" leftNavComponent="LeftNavCompTwo" />
>
> Both LeftNavCompOne and LeftNavCompTwo are components in themselves, but
which
> one gets used by the border component gets decided by the page creator,
not the
> border creator.
>
> I'm not sure how to pass into a parameter that's a component. Can i??
>
> If someone could show me how, that would rock!!
>
> Thanks,
> mark
>
>
>
> ---------------------------------------------------------------------
> 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: Passing Component to Component

Posted by mark lilly <mi...@tinorb.com>.
Jamie Orchard-Hays <jamie <at> dang.com> writes:

> 
> No, you're missing it.
> 
> <parameter name="leftNavComponent" type="name.of.your.ComponentClass"
> direction="in"/>
> 
> is the definition of your parameter in the Border.jwc.
> 
> In PageOne.html:
> 
> <jwcid=" <at> Border" leftNavComponent="LeftNavCompOne" />
> 
> In PageTwo.html
> <jwcid=" <at> Border" leftNavComponent="LeftNavCompTwo" />
> 
> You pass them in and have code in your Border component to deal with the
> different kinds. If they implement an interface that your Border expects,
> you're all set.
> 
> Or, am I missing what you're trying to do?
> 
> Jamie


OK, you're on target. Like i said, dense on this end. You're being super 
helpful!!

Now, in the border component, i have the String "name.of.your.ComponentClass" 
bound to parameter leftNavComponent, passed in from each page. That's great. 
That string name is the class name of the component i want to use for the Left 
Nav. But i can't have a component in the border like this, can i?

  <component id="theLeftNav" type=leftNavComponent />

My question: how do i, in the Border.jwc, turn that string (leftNavComponent 
with a value of "name.of.your.ComponentClass") into a component that can be 
included, essentially, dynamically in the Border.html file, such as:


in Border.html
<jwcid=" <at> theLeftNav" />

Thanks again!
mark




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Passing Component to Component

Posted by Jamie Orchard-Hays <ja...@dang.com>.
No, you're missing it.

<parameter name="leftNavComponent" type="name.of.your.ComponentClass"
direction="in"/>

is the definition of your parameter in the Border.jwc.

In PageOne.html:

<jwcid="@Border" leftNavComponent="LeftNavCompOne" />

In PageTwo.html
<jwcid="@Border" leftNavComponent="LeftNavCompTwo" />

You pass them in and have code in your Border component to deal with the
different kinds. If they implement an interface that your Border expects,
you're all set.

Or, am I missing what you're trying to do?

Jamie

----- Original Message ----- 
From: "mark lilly" <mi...@tinorb.com>
To: <ta...@jakarta.apache.org>
Sent: Thursday, October 07, 2004 6:18 PM
Subject: Re: Passing Component to Component


> Jamie Orchard-Hays <jamie <at> dang.com> writes:
>
> >
> > In your Border.jwc you need to create parameters (direction="in"):
> >
> > <parameter name="leftNavComponent" type="name.of.your.ComponentClass"
> > direction="in"/>
> >
> > Is that enough of a hint?
> >
> > Jamie
>
> I was thinking of that, but i don't want to have to decide the component
class
> in the border. i want each page to be able to choose which component to
use as
> the left nav. i was thinking that i could have in the border class this:
>
> <parameter name="leftNav" type="org.apache.tapestry.AbstractComponent" />
>
> But then how do i "late bind" the actual type of compenent on a page by
page
> basis???
>
> Thanks,
> mark
>
>
> <snip orig>
>
>
> ---------------------------------------------------------------------
> 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: Passing Component to Component

Posted by mark lilly <mi...@tinorb.com>.
Jamie Orchard-Hays <jamie <at> dang.com> writes:

> 
> In your Border.jwc you need to create parameters (direction="in"):
> 
> <parameter name="leftNavComponent" type="name.of.your.ComponentClass"
> direction="in"/>
> 
> Is that enough of a hint?
> 
> Jamie

I was thinking of that, but i don't want to have to decide the component class 
in the border. i want each page to be able to choose which component to use as 
the left nav. i was thinking that i could have in the border class this:

<parameter name="leftNav" type="org.apache.tapestry.AbstractComponent" />

But then how do i "late bind" the actual type of compenent on a page by page 
basis???

Thanks,
mark


<snip orig>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Passing Component to Component

Posted by Jamie Orchard-Hays <ja...@dang.com>.
In your Border.jwc you need to create parameters (direction="in"):

<parameter name="leftNavComponent" type="name.of.your.ComponentClass"
direction="in"/>

Is that enough of a hint?

Jamie

----- Original Message ----- 
From: "mark lilly" <mi...@tinorb.com>
To: <ta...@jakarta.apache.org>
Sent: Thursday, October 07, 2004 6:02 PM
Subject: Passing Component to Component


> HI,
> I'm feeling dense, as if i'm so close to figuring this out, but...
> I need some help.
>
> I have a border component. Typical. Imagine Header, Left Nav and Body
sections.
>
> The Header i can code in the body.html, but i want the Lef Nav to be
> parameterized, so i can create two html pages like this:
>
> pageOne.html
> <jwcid="@Border" leftNavComponent="LeftNavCompOne" />
>
> pageTwo.html
> <jwcid="@Border" leftNavComponent="LeftNavCompTwo" />
>
> Both LeftNavCompOne and LeftNavCompTwo are components in themselves, but
which
> one gets used by the border component gets decided by the page creator,
not the
> border creator.
>
> I'm not sure how to pass into a parameter that's a component. Can i??
>
> If someone could show me how, that would rock!!
>
> Thanks,
> mark
>
>
>
> ---------------------------------------------------------------------
> 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