You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2011/07/21 20:22:24 UTC

Pass component property into page.

Does anybody know how to pass a prop:value from the component back to the
page? I know how to do this very easily from the page to the component, just
not in reverse. 

I tried 

***Custom Component***

<div title="prop:title"




***Page***

<t:Layout title="title"
<t:mycomponent title="title"

@Parameter(required = true)
@Property    
private String title;




***Layout component***

<t:Layout title="title" 

@Parameter(required = true)
@Property    
private String title;


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-property-into-page-tp4620541p4620541.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Pass component property into page.

Posted by George Christman <gc...@cardaddy.com>.
ah okay, Thanks 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-property-into-page-tp4620541p4620616.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Pass component property into page.

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hi!

On Thu, 21 Jul 2011 17:48:37 -0300, Josh Canfield <jo...@gmail.com>  
wrote:

> I'm not sure how this helps the OPs problem though.
>
> BeginRender for your component is going to happen after the layout
> component has started rendering, and already output the title. Right?

Right!

>
> <t:layout title="title">
> <t:mycomponent title="title">
> </t:layout>
>
> t:mycomponent won't get a BeginRender until layout evaluates the  
> <t:body/>

Yes, but in @AfterRender he will be able to use a little bit of DOM  
rewriting to change the page title if needed. ;)
If the title is given the "headTitle" id, it's just a matter of

void afterRender(MarkupWriter writer) {
	String newTitle = ...;
	Element element = writer.getDocument.getElementById("headTitle");
	element.removeChildren();
	element.text(newTitle);
}

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Pass component property into page.

Posted by Josh Canfield <jo...@gmail.com>.
> You'll need to use the Environmental service in your page and add some
> custom object on it, typically in @BeginRender. Then, in your component, you
> invoke some method in this object. In the page, in some event after
> @BeginRender, you get the value back.

I'm not sure how this helps the OPs problem though.

BeginRender for your component is going to happen after the layout
component has started rendering, and already output the title. Right?

<t:layout title="title">
<t:mycomponent title="title">
</t:layout>

t:mycomponent won't get a BeginRender until layout evaluates the <t:body/>

Maybe if you help us understand what you want to accomplish we can
come up with another way?

For instance, if you want your t:mycomponent to actually render the
title and nothing else then you can pass it as a parameter to the
layout

<t:layout>
<p:title><t:mycomponent/></p:title>
</t:layout>

in t:layout you'd do something like

 @Parameter(name = "title")
 @Property
 private Block titleBlock;


<title><t:delegate to="titleBlock"/></title>

Josh

On Thu, Jul 21, 2011 at 11:36 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Thu, 21 Jul 2011 15:32:27 -0300, George Christman
> <gc...@cardaddy.com> wrote:
>
>> Yes, in my example I'm trying to pass a title generated in the page
>> component back to the layout component.
>
> Tapestry's philosophy is that components (including pages) are and should be
> black boxes, so the normal flow is from top to down, not the opposite.
>
> You'll need to use the Environmental service in your page and add some
> custom object on it, typically in @BeginRender. Then, in your component, you
> invoke some method in this object. In the page, in some event after
> @BeginRender, you get the value back.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Pass component property into page.

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 22 Jul 2011 09:12:33 -0300, George Christman  
<gc...@cardaddy.com> wrote:

> Thanks everyone. I only used the title as a simple example to figure out  
> if components were bi directional.

Components aren't bidirectional. Bindings (used in component parameters)  
can be bidirectional. The prop binding is bidirectional. And having pages  
relying on components code is not recommended.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Pass component property into page.

Posted by George Christman <gc...@cardaddy.com>.
Thanks everyone. I only used the title as a simple example to figure out if
components were bi directional. I use two pages, create and update which
render the component containing all the page data within the page. There's
times I need to get some of those values back to the layout component  from
the page component and I couldn't seem to get it working using the simple
@Parameter / @Property approach. I ended up just creating a simple method
within my page using the same object passed into the page component. I was
just looking for a bi directional relationship so I wouldn't have to
replicate code between the create and update pages.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-property-into-page-tp4620541p4622828.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Pass component property into page.

Posted by Igor Drobiazko <ig...@gmail.com>.
Just as a side note: Environmental is not the only way. Component parameters
are actually bidirectional. For example property bindings are writable. A
component parameter is not limited to provide values for components. It may
be used to populate a value from the component to its container. A good
example is Loop component's value parameter which is used by Loop to
"communicate" with its container.

On Thu, Jul 21, 2011 at 8:36 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Thu, 21 Jul 2011 15:32:27 -0300, George Christman <
> gchristman@cardaddy.com> wrote:
>
> Tapestry's philosophy is that components (including pages) are and should
> be black boxes, so the normal flow is from top to down, not the opposite.
>
> You'll need to use the Environmental service in your page and add some
> custom object on it, typically in @BeginRender. Then, in your component, you
> invoke some method in this object. In the page, in some event after
> @BeginRender, you get the value back.



-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Re: Pass component property into page.

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 21 Jul 2011 15:32:27 -0300, George Christman  
<gc...@cardaddy.com> wrote:

> Yes, in my example I'm trying to pass a title generated in the page  
> component back to the layout component.

Tapestry's philosophy is that components (including pages) are and should  
be black boxes, so the normal flow is from top to down, not the opposite.

You'll need to use the Environmental service in your page and add some  
custom object on it, typically in @BeginRender. Then, in your component,  
you invoke some method in this object. In the page, in some event after  
@BeginRender, you get the value back.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Pass component property into page.

Posted by George Christman <gc...@cardaddy.com>.
Yes, in my example I'm trying to pass a title generated in the page component
back to the layout component. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-property-into-page-tp4620541p4620575.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Pass component property into page.

Posted by Josh Canfield <jo...@gmail.com>.
Pages don't have parameters. It's not really clear to me from your
example what it is you're trying to do.

Are you trying to have your component define the title of the page?



On Thu, Jul 21, 2011 at 11:22 AM, George Christman
<gc...@cardaddy.com> wrote:
> Does anybody know how to pass a prop:value from the component back to the
> page? I know how to do this very easily from the page to the component, just
> not in reverse.
>
> I tried
>
> ***Custom Component***
>
> <div title="prop:title"
>
>
>
>
> ***Page***
>
> <t:Layout title="title"
> <t:mycomponent title="title"
>
> @Parameter(required = true)
> @Property
> private String title;
>
>
>
>
> ***Layout component***
>
> <t:Layout title="title"
>
> @Parameter(required = true)
> @Property
> private String title;
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-property-into-page-tp4620541p4620541.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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