You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jeshurun Daniel <sj...@yahoo.ca> on 2010/10/18 21:19:34 UTC

Component parameters-unintended persistent binding

Hi everyone,
This is a really strange problem I'm having with component parameters and I've spent a whole day on this and I'm still clueless.

I have three components, a custom layout component, a menu component and a breadcrumb component. The menu and breadcrumb components are contained within the layout component. They each have a required parameter, mainMenuId and breadcrumbId, which is used to render the menu / breadcrumb recursively from the database. These parameters are bound to the containing layout component, and I pass them to the layout component from the page. So for example say on one page I only want the menu and not the breadcrumbs, i use an if in the layout component to check if the menuId is bound like this.<t:if test="mainMenuId"><t:mainMenu /></t:if>The breadcrumbs work the same way.
This works fine. Now here is where I am getting confused. In the Index page, I'm displaying the menu, but I'm not showing the breadcrumbs. No problem. In the next page, I'm just displaying the breadcrumbs without the menu. This works fine as well. 
But when I look at the logs when rendering the second page, I see that the mainMenuId getters have been called, and the database queries in the menu component have run, even though the menu itself is not shown in the page. I printed out the value and it is what I set on the index page, even though this page is in no way related to the index page, and this page does not provide any values for the mainMenuId parameter However, if I restart the server and go directly to the second page, then I dont see the queries and the values are not bound.
Here is how I'm passing the value from the Index page<div t:type="MyTheme"
 t:mainMenuId="1" >

And this is how it looks in the second page<div t:type="MyTheme" t:breadcrumbId="11" />
I tried clearing the values using @afterrender in the layout component, and set the parameters as property bindings instead of literals, with no luck. I still don't completely understand the page / component life cycle and so this is a little confusing to me. If anyone could give me any pointers I would greatly appreciate it.
Thanks in advance,Jeshurun



Re: Component parameters-unintended persistent binding

Posted by Rich M <ri...@moremagic.com>.
This may not be entirely your issue, but the t:if test parameter takes 
in property bindings, so I believe that is why it would be calling the 
getters on the mainMenuId even if it were blank/null on the second page. 
What happens if you have the test parameter link to a boolean method 
that handles whether or not the mainMenuId is null/blank rather than 
relying on the property binding and String->boolean conversion? I can't 
speak beyond as to why it would be loading a different value here in the 
second page.

On 10/18/2010 03:19 PM, Jeshurun Daniel wrote:
> Hi everyone,
> This is a really strange problem I'm having with component parameters and I've spent a whole day on this and I'm still clueless.
>
> I have three components, a custom layout component, a menu component and a breadcrumb component. The menu and breadcrumb components are contained within the layout component. They each have a required parameter, mainMenuId and breadcrumbId, which is used to render the menu / breadcrumb recursively from the database. These parameters are bound to the containing layout component, and I pass them to the layout component from the page. So for example say on one page I only want the menu and not the breadcrumbs, i use an if in the layout component to check if the menuId is bound like this.<t:if test="mainMenuId"><t:mainMenu /></t:if>The breadcrumbs work the same way.
> This works fine. Now here is where I am getting confused. In the Index page, I'm displaying the menu, but I'm not showing the breadcrumbs. No problem. In the next page, I'm just displaying the breadcrumbs without the menu. This works fine as well. 
> But when I look at the logs when rendering the second page, I see that the mainMenuId getters have been called, and the database queries in the menu component have run, even though the menu itself is not shown in the page. I printed out the value and it is what I set on the index page, even though this page is in no way related to the index page, and this page does not provide any values for the mainMenuId parameter However, if I restart the server and go directly to the second page, then I dont see the queries and the values are not bound.
> Here is how I'm passing the value from the Index page<div t:type="MyTheme"
>   t:mainMenuId="1">
>
> And this is how it looks in the second page<div t:type="MyTheme" t:breadcrumbId="11" />
> I tried clearing the values using @afterrender in the layout component, and set the parameters as property bindings instead of literals, with no luck. I still don't completely understand the page / component life cycle and so this is a little confusing to me. If anyone could give me any pointers I would greatly appreciate it.
> Thanks in advance,Jeshurun
>
>
>
>    


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


Re: Component parameters-unintended persistent binding

Posted by Howard Lewis Ship <hl...@gmail.com>.
I'm confused from your description.  I'm sure its something minor, but
we'd need to know the version you are using, plus more details from
your .tml and .java files to figure out what's going on.

On Mon, Oct 18, 2010 at 12:19 PM, Jeshurun Daniel <sj...@yahoo.ca> wrote:
> Hi everyone,
> This is a really strange problem I'm having with component parameters and I've spent a whole day on this and I'm still clueless.
>
> I have three components, a custom layout component, a menu component and a breadcrumb component. The menu and breadcrumb components are contained within the layout component. They each have a required parameter, mainMenuId and breadcrumbId, which is used to render the menu / breadcrumb recursively from the database. These parameters are bound to the containing layout component, and I pass them to the layout component from the page. So for example say on one page I only want the menu and not the breadcrumbs, i use an if in the layout component to check if the menuId is bound like this.<t:if test="mainMenuId"><t:mainMenu /></t:if>The breadcrumbs work the same way.
> This works fine. Now here is where I am getting confused. In the Index page, I'm displaying the menu, but I'm not showing the breadcrumbs. No problem. In the next page, I'm just displaying the breadcrumbs without the menu. This works fine as well.
> But when I look at the logs when rendering the second page, I see that the mainMenuId getters have been called, and the database queries in the menu component have run, even though the menu itself is not shown in the page. I printed out the value and it is what I set on the index page, even though this page is in no way related to the index page, and this page does not provide any values for the mainMenuId parameter However, if I restart the server and go directly to the second page, then I dont see the queries and the values are not bound.
> Here is how I'm passing the value from the Index page<div t:type="MyTheme"
>  t:mainMenuId="1" >
>
> And this is how it looks in the second page<div t:type="MyTheme" t:breadcrumbId="11" />
> I tried clearing the values using @afterrender in the layout component, and set the parameters as property bindings instead of literals, with no luck. I still don't completely understand the page / component life cycle and so this is a little confusing to me. If anyone could give me any pointers I would greatly appreciate it.
> Thanks in advance,Jeshurun
>
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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