You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2007/07/30 23:02:00 UTC

Nesting tiles 3 levels deep not finding attribute

Hello:

I have 3 levels of nested tiles:

  <definition name="layout" template="/layout.jsp">
    <put-attribute name="top" value="/top.jsp" />
    <put-attribute name="banner" value="/banner.jsp" />
    <put-attribute name="footer" value="/footer.jsp" />
  </definition>

  <definition name="product.nav" template="/productNavLayout.jsp">
    <put-attribute name="productPathNav" value="/productPathNav.jsp" />
    <put-attribute name="productNav" value="/productNav.jsp" />
  </definition>

  <definition name="product.grid" template="/productGridLayout.jsp">
    <put-attribute name="productGridTopNav" value="/productGridTopNav.jsp"
/>
    <put-attribute name="productGrid" value="/productGrid.jsp" />
    <put-attribute name="productGridBottomNav"
value="/productGridBottomNav.jsp" />
  </definition>

  <definition name="page.products" extends="layout">
    <put-attribute name="content" value="product.nav" />
    <put-attribute name="productContent" value="product.grid" />
  </definition>

For some reason, when I load the page.products definition, I
get this error:

javax.servlet.jsp.JspException: Error executing tag: Attribute
'productContent' not found.
        at
org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagS
upport.java:80)
        at
org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport
.java:80)
        at
org.apache.jsp.productNavLayout_jsp._jspx_meth_tiles_005finsertAttribute_005
f2(productNavLayout_jsp.java:170)

But, as you can see, the page.products definition defines productContent
directly.

Any ides what is going on here?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


Re: Nesting tiles 3 levels deep not finding attribute

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
> I did not understand what the statement was saying without
> the example.  Maybe you should add the example to the FAQ
> entry.

You're right but I was too lazy :-P

Antonio

Re: Nesting tiles 3 levels deep not finding attribute

Posted by Marcus Oenicke <m....@it4u-berlin.biz>.
Oh yes, to be sure it did.
In fact, starting with the tutorial on "Nesting and Extension" it seemed
quite natural to do that.
If that was an "unintentional feature" I happened to uncover - what a pity.

But thanks a lot for your patience, I'll follow that JIRA-link.

Cheers, Marcus


Antonio Petrelli-3 wrote:
> 
> Do you mean that your example worked? :-O
> If yes, it was a bug, or better an unintentional feature :-)
> There is a JIRA issue to support "pass through" attributes, if you are
> interested:
> https://issues.apache.org/struts/browse/TILES-208
> 
> Antonio
> 
> 2007/10/8, Marcus Oenicke <m....@it4u-berlin.biz>:
>>
>> Err...sorry if you found my post confusing.
>>
>> Let me give you an example.
>> I had the following definitions working with Struts 2.0.6 and its Tiles
>> plug-in.
>>
>> A "master" template for the basic layout:
>>
>> <definition name="main" template="/jsp/templates/main.jsp">
>>         <put-attribute name="header" type="definition" value="hv.header"
>> />
>>         <put-attribute name="page.title" type="string" value="" />
>>         <put-attribute name="contentarea" type="template"
>> value="/jsp/tiles/blank.jsp" />
>>         <put-attribute name="footer" type="definition" value="hv.footer"
>> />
>> </definition>
>>
>> A basic header definition:
>>
>> <definition name="header" template="/jsp/templates/header.jsp">
>>         <put-attribute name="header.text" type="string"
>> value="Application Name" />
>>         <put-attribute name="header.title" type="string" value="" />
>> </definition>
>>
>> A specialized layout for simple input forms extending "main":
>>
>> <definition name="form.simple" extends="main">
>>         <put-attribute name="intro.header" value="" />
>>         <put-attribute name="intro.text" value="" />
>>         <put-attribute name="contentarea" type="template"
>> value="/jsp/templates/form-simple.jsp" />
>>         <put-attribute name="form.body" type="template"
>> value="/jsp/tiles/blank.jsp" />
>> </definition>
>>
>> It overwrites the attribute "contentarea" from definition "main" with a
>> more
>> specialized template which in turn adds the attributes "intro.header",
>> "intro.text" and "form.body".
>>
>> And finally I defined a login page by extending "form.simple":
>>
>> <definition name="login" extends="form.simple">
>>         <put-attribute name="header.title" type="string" value="Login" />
>>         <put-attribute name="page.title" type="string" value="Login" />
>>         <put-attribute name="intro.header" type="string" value="Please
>> login" />
>>         <put-attribute name="form.body" type="template"
>> value="/jsp/tiles/login.jsp" />
>> </definition>
>>
>> This one overwrites "header.title" from definition "header", "page.title"
>> from definition "main", "intro.header" and "form.body" from definition
>> "form.simple".
>>
>> However, with Struts 2.0.9 and its Tiles plug-in (which is equivalent to
>> v
>> 2.0.4) I got the "Attribute not found" error for all attributes of
>> "login",
>> except "page.title", just like Neil.
>>
>> With the help of the example you gave in this thread I rearrangend my
>> definitions as follows (only the changed definitions shown).
>>
>> Definitions "form.simple" does not extend "main" and does not attempt to
>> overwrite its attribute "contentarea", but references the template
>> directly:
>>
>> <definition name="form.simple" template="/jsp/templates/form-simple.jsp">
>>         <put-attribute name="intro.header" value="" />
>>         <put-attribute name="intro.text" value="" />
>>         <put-attribute name="form.body" type="template"
>> value="/jsp/tiles/blank.jsp" />
>> </definition>
>>
>> The "login" definition now extends "main" and uses extra definitions
>> ("login.header" and "login.body") to insert into "main" as tiles:
>>
>> <definition name="login" extends="main">
>>         <put-attribute name="header" type="definition"
>> value="login.header"/>
>>         <put-attribute name="page.title" type="string" value="Login" />
>>         <put-attribute name="contentarea" type="definition"
>> value="login.body" />
>> </definition>
>>
>> This definition fills relevant attributes of definition "header":
>>
>> <definition name="login.header" extends="header">
>>         <put-attribute name="header.title" type="string" value="Login" />
>> </definition>
>>
>> This definition fills relevant attributes of definition "form.simple":
>> <definition name="login.body" extends="form.simple">
>>         <put-attribute name="intro.header" type="string" value="Please
>> login" />
>>         <put-attribute name="form.body" type="template"
>> value="/jsp/tiles/login.jsp" />
>> </definition>
>>
>> It works, but now I need more than one definition per rendered page (like
>> "login").
>> This is the change I was referring to.
>>
>> Marcus
>>
>>
>> Antonio Petrelli-3 wrote:
>> >
>> > 2007/10/8, Marcus Oenicke <m....@it4u-berlin.biz>:
>> >>
>> >>
>> >> Antonio,
>> >> I had the same problem when upgrading from Struts 2.0.6 to Struts
>> 2.0.9.
>> >>
>> >> If I get you right, it breaks down to:
>> >> you can extend templates, but not tiles.
>> >>
>> >> Templates can represent whole pages or parts of them.
>> >> To use templates as tiles (i.e. for a sub-page), you need a separate
>> >> definition to fill the attributes of that template.
>> >> And only such a definition can be used as a tile in the page
>> definition
>> >> which may extend the master template.
>> >> Is that right?
>> >>
>> >> But this behaviour is different to that of the Tiles plugin of Struts
>> >> 2.0.6.
>> >> There it was possible to extend a master template in various levels
>> into
>> >> more specialized templates adding extra attributes and sub-page
>> templates
>> >> on
>> >> the way while being able to overwrite any attribute of any previous
>> >> level.
>> >>
>> >> Is there a special reason for that change?
>> >
>> >
>> >
>> > Err... sorry but I cannot follow you :-O
>> > You can extend *definitions*, but you *cannot* extend templates or
>> > attributes (BTW, probably the concept of "extension" does not make
>> sense
>> > here).
>> > With the extension of a definition you can override attributes and the
>> > template of that definition.
>> > This behaviour has never changed since Struts-Tiles.
>> >
>> > Antonio
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Nesting-tiles-3-levels-deep-not-finding-attribute-tf4179213.html#a13099931
>> Sent from the tiles users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Nesting-tiles-3-levels-deep-not-finding-attribute-tf4179213.html#a13109645
Sent from the tiles users mailing list archive at Nabble.com.


Re: Nesting tiles 3 levels deep not finding attribute

Posted by Antonio Petrelli <an...@gmail.com>.
Do you mean that your example worked? :-O
If yes, it was a bug, or better an unintentional feature :-)
There is a JIRA issue to support "pass through" attributes, if you are
interested:
https://issues.apache.org/struts/browse/TILES-208

Antonio

2007/10/8, Marcus Oenicke <m....@it4u-berlin.biz>:
>
> Err...sorry if you found my post confusing.
>
> Let me give you an example.
> I had the following definitions working with Struts 2.0.6 and its Tiles
> plug-in.
>
> A "master" template for the basic layout:
>
> <definition name="main" template="/jsp/templates/main.jsp">
>         <put-attribute name="header" type="definition" value="hv.header" />
>         <put-attribute name="page.title" type="string" value="" />
>         <put-attribute name="contentarea" type="template"
> value="/jsp/tiles/blank.jsp" />
>         <put-attribute name="footer" type="definition" value="hv.footer" />
> </definition>
>
> A basic header definition:
>
> <definition name="header" template="/jsp/templates/header.jsp">
>         <put-attribute name="header.text" type="string" value="Application Name" />
>         <put-attribute name="header.title" type="string" value="" />
> </definition>
>
> A specialized layout for simple input forms extending "main":
>
> <definition name="form.simple" extends="main">
>         <put-attribute name="intro.header" value="" />
>         <put-attribute name="intro.text" value="" />
>         <put-attribute name="contentarea" type="template"
> value="/jsp/templates/form-simple.jsp" />
>         <put-attribute name="form.body" type="template"
> value="/jsp/tiles/blank.jsp" />
> </definition>
>
> It overwrites the attribute "contentarea" from definition "main" with a more
> specialized template which in turn adds the attributes "intro.header",
> "intro.text" and "form.body".
>
> And finally I defined a login page by extending "form.simple":
>
> <definition name="login" extends="form.simple">
>         <put-attribute name="header.title" type="string" value="Login" />
>         <put-attribute name="page.title" type="string" value="Login" />
>         <put-attribute name="intro.header" type="string" value="Please login" />
>         <put-attribute name="form.body" type="template"
> value="/jsp/tiles/login.jsp" />
> </definition>
>
> This one overwrites "header.title" from definition "header", "page.title"
> from definition "main", "intro.header" and "form.body" from definition
> "form.simple".
>
> However, with Struts 2.0.9 and its Tiles plug-in (which is equivalent to v
> 2.0.4) I got the "Attribute not found" error for all attributes of "login",
> except "page.title", just like Neil.
>
> With the help of the example you gave in this thread I rearrangend my
> definitions as follows (only the changed definitions shown).
>
> Definitions "form.simple" does not extend "main" and does not attempt to
> overwrite its attribute "contentarea", but references the template directly:
>
> <definition name="form.simple" template="/jsp/templates/form-simple.jsp">
>         <put-attribute name="intro.header" value="" />
>         <put-attribute name="intro.text" value="" />
>         <put-attribute name="form.body" type="template"
> value="/jsp/tiles/blank.jsp" />
> </definition>
>
> The "login" definition now extends "main" and uses extra definitions
> ("login.header" and "login.body") to insert into "main" as tiles:
>
> <definition name="login" extends="main">
>         <put-attribute name="header" type="definition" value="login.header"/>
>         <put-attribute name="page.title" type="string" value="Login" />
>         <put-attribute name="contentarea" type="definition" value="login.body" />
> </definition>
>
> This definition fills relevant attributes of definition "header":
>
> <definition name="login.header" extends="header">
>         <put-attribute name="header.title" type="string" value="Login" />
> </definition>
>
> This definition fills relevant attributes of definition "form.simple":
> <definition name="login.body" extends="form.simple">
>         <put-attribute name="intro.header" type="string" value="Please login" />
>         <put-attribute name="form.body" type="template"
> value="/jsp/tiles/login.jsp" />
> </definition>
>
> It works, but now I need more than one definition per rendered page (like
> "login").
> This is the change I was referring to.
>
> Marcus
>
>
> Antonio Petrelli-3 wrote:
> >
> > 2007/10/8, Marcus Oenicke <m....@it4u-berlin.biz>:
> >>
> >>
> >> Antonio,
> >> I had the same problem when upgrading from Struts 2.0.6 to Struts 2.0.9.
> >>
> >> If I get you right, it breaks down to:
> >> you can extend templates, but not tiles.
> >>
> >> Templates can represent whole pages or parts of them.
> >> To use templates as tiles (i.e. for a sub-page), you need a separate
> >> definition to fill the attributes of that template.
> >> And only such a definition can be used as a tile in the page definition
> >> which may extend the master template.
> >> Is that right?
> >>
> >> But this behaviour is different to that of the Tiles plugin of Struts
> >> 2.0.6.
> >> There it was possible to extend a master template in various levels into
> >> more specialized templates adding extra attributes and sub-page templates
> >> on
> >> the way while being able to overwrite any attribute of any previous
> >> level.
> >>
> >> Is there a special reason for that change?
> >
> >
> >
> > Err... sorry but I cannot follow you :-O
> > You can extend *definitions*, but you *cannot* extend templates or
> > attributes (BTW, probably the concept of "extension" does not make sense
> > here).
> > With the extension of a definition you can override attributes and the
> > template of that definition.
> > This behaviour has never changed since Struts-Tiles.
> >
> > Antonio
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Nesting-tiles-3-levels-deep-not-finding-attribute-tf4179213.html#a13099931
> Sent from the tiles users mailing list archive at Nabble.com.
>
>

Re: Nesting tiles 3 levels deep not finding attribute

Posted by Marcus Oenicke <m....@it4u-berlin.biz>.
Err...sorry if you found my post confusing.

Let me give you an example.
I had the following definitions working with Struts 2.0.6 and its Tiles
plug-in.

A "master" template for the basic layout:

<definition name="main" template="/jsp/templates/main.jsp">
	<put-attribute name="header" type="definition" value="hv.header" />
	<put-attribute name="page.title" type="string" value="" />
	<put-attribute name="contentarea" type="template"
value="/jsp/tiles/blank.jsp" />
	<put-attribute name="footer" type="definition" value="hv.footer" />
</definition>

A basic header definition:

<definition name="header" template="/jsp/templates/header.jsp">
	<put-attribute name="header.text" type="string" value="Application Name" />
	<put-attribute name="header.title" type="string" value="" />
</definition>

A specialized layout for simple input forms extending "main":

<definition name="form.simple" extends="main">
	<put-attribute name="intro.header" value="" />
	<put-attribute name="intro.text" value="" />
	<put-attribute name="contentarea" type="template"
value="/jsp/templates/form-simple.jsp" />
	<put-attribute name="form.body" type="template"
value="/jsp/tiles/blank.jsp" />
</definition>

It overwrites the attribute "contentarea" from definition "main" with a more
specialized template which in turn adds the attributes "intro.header",
"intro.text" and "form.body".

And finally I defined a login page by extending "form.simple":

<definition name="login" extends="form.simple">
	<put-attribute name="header.title" type="string" value="Login" />
	<put-attribute name="page.title" type="string" value="Login" />
	<put-attribute name="intro.header" type="string" value="Please login" />
	<put-attribute name="form.body" type="template"
value="/jsp/tiles/login.jsp" />
</definition>
	
This one overwrites "header.title" from definition "header", "page.title"
from definition "main", "intro.header" and "form.body" from definition
"form.simple".

However, with Struts 2.0.9 and its Tiles plug-in (which is equivalent to v
2.0.4) I got the "Attribute not found" error for all attributes of "login",
except "page.title", just like Neil.

With the help of the example you gave in this thread I rearrangend my
definitions as follows (only the changed definitions shown).

Definitions "form.simple" does not extend "main" and does not attempt to
overwrite its attribute "contentarea", but references the template directly:

<definition name="form.simple" template="/jsp/templates/form-simple.jsp">
	<put-attribute name="intro.header" value="" />
	<put-attribute name="intro.text" value="" />
	<put-attribute name="form.body" type="template"
value="/jsp/tiles/blank.jsp" />
</definition>
	
The "login" definition now extends "main" and uses extra definitions
("login.header" and "login.body") to insert into "main" as tiles:

<definition name="login" extends="main">
	<put-attribute name="header" type="definition" value="login.header"/>
	<put-attribute name="page.title" type="string" value="Login" />
	<put-attribute name="contentarea" type="definition" value="login.body" />
</definition>

This definition fills relevant attributes of definition "header":

<definition name="login.header" extends="header">
	<put-attribute name="header.title" type="string" value="Login" />
</definition>

This definition fills relevant attributes of definition "form.simple":	
<definition name="login.body" extends="form.simple">
	<put-attribute name="intro.header" type="string" value="Please login" />
	<put-attribute name="form.body" type="template"
value="/jsp/tiles/login.jsp" />
</definition>
	
It works, but now I need more than one definition per rendered page (like
"login").
This is the change I was referring to.

Marcus


Antonio Petrelli-3 wrote:
> 
> 2007/10/8, Marcus Oenicke <m....@it4u-berlin.biz>:
>>
>>
>> Antonio,
>> I had the same problem when upgrading from Struts 2.0.6 to Struts 2.0.9.
>>
>> If I get you right, it breaks down to:
>> you can extend templates, but not tiles.
>>
>> Templates can represent whole pages or parts of them.
>> To use templates as tiles (i.e. for a sub-page), you need a separate
>> definition to fill the attributes of that template.
>> And only such a definition can be used as a tile in the page definition
>> which may extend the master template.
>> Is that right?
>>
>> But this behaviour is different to that of the Tiles plugin of Struts
>> 2.0.6.
>> There it was possible to extend a master template in various levels into
>> more specialized templates adding extra attributes and sub-page templates
>> on
>> the way while being able to overwrite any attribute of any previous
>> level.
>>
>> Is there a special reason for that change?
> 
> 
> 
> Err... sorry but I cannot follow you :-O
> You can extend *definitions*, but you *cannot* extend templates or
> attributes (BTW, probably the concept of "extension" does not make sense
> here).
> With the extension of a definition you can override attributes and the
> template of that definition.
> This behaviour has never changed since Struts-Tiles.
> 
> Antonio
> 
> 

-- 
View this message in context: http://www.nabble.com/Nesting-tiles-3-levels-deep-not-finding-attribute-tf4179213.html#a13099931
Sent from the tiles users mailing list archive at Nabble.com.


Re: Nesting tiles 3 levels deep not finding attribute

Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/8, Marcus Oenicke <m....@it4u-berlin.biz>:
>
>
> Antonio,
> I had the same problem when upgrading from Struts 2.0.6 to Struts 2.0.9.
>
> If I get you right, it breaks down to:
> you can extend templates, but not tiles.
>
> Templates can represent whole pages or parts of them.
> To use templates as tiles (i.e. for a sub-page), you need a separate
> definition to fill the attributes of that template.
> And only such a definition can be used as a tile in the page definition
> which may extend the master template.
> Is that right?
>
> But this behaviour is different to that of the Tiles plugin of Struts
> 2.0.6.
> There it was possible to extend a master template in various levels into
> more specialized templates adding extra attributes and sub-page templates
> on
> the way while being able to overwrite any attribute of any previous level.
>
> Is there a special reason for that change?



Err... sorry but I cannot follow you :-O
You can extend *definitions*, but you *cannot* extend templates or
attributes (BTW, probably the concept of "extension" does not make sense
here).
With the extension of a definition you can override attributes and the
template of that definition.
This behaviour has never changed since Struts-Tiles.

Antonio

Re: Nesting tiles 3 levels deep not finding attribute

Posted by Marcus Oenicke <m....@it4u-berlin.biz>.
Antonio,
I had the same problem when upgrading from Struts 2.0.6 to Struts 2.0.9.

If I get you right, it breaks down to:
you can extend templates, but not tiles.

Templates can represent whole pages or parts of them.
To use templates as tiles (i.e. for a sub-page), you need a separate
definition to fill the attributes of that template.
And only such a definition can be used as a tile in the page definition
which may extend the master template.
Is that right?

But this behaviour is different to that of the Tiles plugin of Struts 2.0.6.
There it was possible to extend a master template in various levels into
more specialized templates adding extra attributes and sub-page templates on
the way while being able to overwrite any attribute of any previous level.

Is there a special reason for that change?


Antonio Petrelli-3 wrote:
> 
> 2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
> 
> The solution is in the second sentence of the FAQ:
> 
> <snip>
> In this case, usually you have to create a new definition extending
> from an existing one, fill the attribute in the correct template and
> assign the new definition as an attribute to the main template.
> </snip>
> 
> In other words:
> 
>  <definition name="product.nav" template="/productNavLayout.jsp">
>    <put-attribute name="productPathNav" value="/productPathNav.jsp" />
>    <put-attribute name="productNav" value="/productNav.jsp" />
>  </definition>
> 
>  <definition name="product.nav.extended" extends="product.nav">
>    <put-attribute name="productContent" value="product.grid" />
>  </definition>
> 
>  <definition name="page.products" extends="layout">
>    <put-attribute name="content" value="product.nav.extended" />
>  </definition>
> 
> HTH
> Antonio
> 

-- 
View this message in context: http://www.nabble.com/Nesting-tiles-3-levels-deep-not-finding-attribute-tf4179213.html#a13087898
Sent from the tiles users mailing list archive at Nabble.com.


RE: Nesting tiles 3 levels deep not finding attribute

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Antonio:

That worked!

I did not understand what the statement was saying without
the example.  Maybe you should add the example to the FAQ
entry.

Thanks,	
	Neil 

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, July 31, 2007 11:42 AM
To: users@tiles.apache.org
Subject: Re: Nesting tiles 3 levels deep not finding attribute

2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
> According to the Tiles FAQ:
>
> I filled an attribute of a template, but it did not get
> in an inner template. What happened?
>
> Attributes must be filled in the correct template. In other words,
> there are no "pass-through" attributes, that you fill in the
> master template and get filled in the inner ones.
> ...
> Is there a way to tell productNavLayout.jsp to
> pull it from layout.jsp's attributes?

The solution is in the second sentence of the FAQ:

<snip>
In this case, usually you have to create a new definition extending
from an existing one, fill the attribute in the correct template and
assign the new definition as an attribute to the main template.
</snip>

In other words:

 <definition name="product.nav" template="/productNavLayout.jsp">
   <put-attribute name="productPathNav" value="/productPathNav.jsp" />
   <put-attribute name="productNav" value="/productNav.jsp" />
 </definition>

 <definition name="product.nav.extended" extends="product.nav">
   <put-attribute name="productContent" value="product.grid" />
 </definition>

 <definition name="page.products" extends="layout">
   <put-attribute name="content" value="product.nav.extended" />
 </definition>

HTH
Antonio
> Thanks,
>         Neil
>
> --
> Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> FREE! Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.


Re: Nesting tiles 3 levels deep not finding attribute

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
> According to the Tiles FAQ:
>
> I filled an attribute of a template, but it did not get
> in an inner template. What happened?
>
> Attributes must be filled in the correct template. In other words,
> there are no "pass-through" attributes, that you fill in the
> master template and get filled in the inner ones.
> ...
> Is there a way to tell productNavLayout.jsp to
> pull it from layout.jsp's attributes?

The solution is in the second sentence of the FAQ:

<snip>
In this case, usually you have to create a new definition extending
from an existing one, fill the attribute in the correct template and
assign the new definition as an attribute to the main template.
</snip>

In other words:

 <definition name="product.nav" template="/productNavLayout.jsp">
   <put-attribute name="productPathNav" value="/productPathNav.jsp" />
   <put-attribute name="productNav" value="/productNav.jsp" />
 </definition>

 <definition name="product.nav.extended" extends="product.nav">
   <put-attribute name="productContent" value="product.grid" />
 </definition>

 <definition name="page.products" extends="layout">
   <put-attribute name="content" value="product.nav.extended" />
 </definition>

HTH
Antonio
> Thanks,
>         Neil
>
> --
> Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> FREE! Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.
>
> -----Original Message-----
> From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com]
> Sent: Tuesday, July 31, 2007 1:58 AM
> To: users@tiles.apache.org
> Subject: Re: Nesting tiles 3 levels deep not finding attribute
>
> 2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
> >
> > Hello:
> >
> > I have been doing some googling on this and I
> > came across this post:
> > http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24016.html
> >
> > So, attributes do not cascade and I have to push them down
> > to the nested tiles.
> >
> > Looking at the syntax on that page, I took a look at
> > the tiles:putAttribute tag but I cannot figure out
> > how to do it.
>
>
>
> I think this is not your case: your Tiles definitions seem to be correctly
> defined. In fact, the attribute "productContent" is bound to definition "
> product.grid", so I think your problem is another.
> First of all, what version of Tiles are you using? Are you using it together
> with a web framework?
> And did you receive errors at the startup of the application?
>
> Antonio
>
>

RE: Nesting tiles 3 levels deep not finding attribute

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Antonio:

I am using tiles 2.0.4 bundled with struts 2.0.9
and the struts-tiles plugin.

I just checked the tomcat log and I don't see any
errors besides the productContent not being found.

Any ideas?

Thanks,
	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, July 31, 2007 1:58 AM
To: users@tiles.apache.org
Subject: Re: Nesting tiles 3 levels deep not finding attribute

2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
>
> Hello:
>
> I have been doing some googling on this and I
> came across this post:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24016.html
>
> So, attributes do not cascade and I have to push them down
> to the nested tiles.
>
> Looking at the syntax on that page, I took a look at
> the tiles:putAttribute tag but I cannot figure out
> how to do it.



I think this is not your case: your Tiles definitions seem to be correctly
defined. In fact, the attribute "productContent" is bound to definition "
product.grid", so I think your problem is another.
First of all, what version of Tiles are you using? Are you using it together
with a web framework?
And did you receive errors at the startup of the application?

Antonio


RE: Nesting tiles 3 levels deep not finding attribute

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Antonio:

I just tried defining productContent in my layout.jsp
page:

<tiles:insertAttribute name="content">
  <tiles:putAttribute name="productContent" value="product.grid" />
</tiles:insertAttribute> 

And the page renders completely correctly.  I definitely
think this is a scoping issue.

Is there a way to tell the putAttribute call above to
pull the value from the attributes of the layout
instead of hard-coding it like I just did?

I tried this to no avail:

<tiles:insertAttribute name="content">
  <tiles:putAttribute name="productContent" value="%{productContent}" />
</tiles:insertAttribute> 

The reason I want to do that is to re-use the
same layout for different nested content.

Here is an example:

  <definition name="page.products" extends="layout">
    <put-attribute name="content" value="product.nav" />
    <put-attribute name="productContent" value="product.grid" />
  </definition>

  <definition name="page.productDetail" extends="layout">
    <put-attribute name="content" value="product.nav" />
    <put-attribute name="productContent" value="/productDetail.jsp" />
  </definition>

These two definitions share the same layout but have different
values for productContent.

How do I achieve this with tiles?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, July 31, 2007 1:58 AM
To: users@tiles.apache.org
Subject: Re: Nesting tiles 3 levels deep not finding attribute

2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
>
> Hello:
>
> I have been doing some googling on this and I
> came across this post:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24016.html
>
> So, attributes do not cascade and I have to push them down
> to the nested tiles.
>
> Looking at the syntax on that page, I took a look at
> the tiles:putAttribute tag but I cannot figure out
> how to do it.



I think this is not your case: your Tiles definitions seem to be correctly
defined. In fact, the attribute "productContent" is bound to definition "
product.grid", so I think your problem is another.
First of all, what version of Tiles are you using? Are you using it together
with a web framework?
And did you receive errors at the startup of the application?

Antonio


RE: Nesting tiles 3 levels deep not finding attribute

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Antonio:

According to the Tiles FAQ:

I filled an attribute of a template, but it did not get 
in an inner template. What happened?

Attributes must be filled in the correct template. In other words, 
there are no "pass-through" attributes, that you fill in the 
master template and get filled in the inner ones.


This looks like what is happening to me.

My page.products definition extends the layout
definition and puts attributes named content
and pageContent.

The layout definition uses layout.jsp which has
a call to insert the content attribute:

<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<html>
  <body bgColor="#ffffff">
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
	  <td><tiles:insertAttribute name="content"/></td>
	</tr>  		
    </table>
  </body>
</html>

I set the content to product.nav which is a nested
tiles definition.  Its layout is productNavLayout.jsp
which tries to access the attribute productContent:

<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top">
      <tiles:insertAttribute name="productContent"/>			
    </td>
  </tr>
</table>			

The productContent attribute seems to be in the scope
for layout.jsp and not in the scope for 
productNavLayout.jsp which is why it can't find it.

Is there a way to tell productNavLayout.jsp to
pull it from layout.jsp's attributes?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, July 31, 2007 1:58 AM
To: users@tiles.apache.org
Subject: Re: Nesting tiles 3 levels deep not finding attribute

2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
>
> Hello:
>
> I have been doing some googling on this and I
> came across this post:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24016.html
>
> So, attributes do not cascade and I have to push them down
> to the nested tiles.
>
> Looking at the syntax on that page, I took a look at
> the tiles:putAttribute tag but I cannot figure out
> how to do it.



I think this is not your case: your Tiles definitions seem to be correctly
defined. In fact, the attribute "productContent" is bound to definition "
product.grid", so I think your problem is another.
First of all, what version of Tiles are you using? Are you using it together
with a web framework?
And did you receive errors at the startup of the application?

Antonio


Re: Nesting tiles 3 levels deep not finding attribute

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/31, Neil Aggarwal <ne...@jammconsulting.com>:
>
> Hello:
>
> I have been doing some googling on this and I
> came across this post:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24016.html
>
> So, attributes do not cascade and I have to push them down
> to the nested tiles.
>
> Looking at the syntax on that page, I took a look at
> the tiles:putAttribute tag but I cannot figure out
> how to do it.



I think this is not your case: your Tiles definitions seem to be correctly
defined. In fact, the attribute "productContent" is bound to definition "
product.grid", so I think your problem is another.
First of all, what version of Tiles are you using? Are you using it together
with a web framework?
And did you receive errors at the startup of the application?

Antonio

RE: Nesting tiles 3 levels deep not finding attribute

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Hello:

I have been doing some googling on this and I
came across this post:
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24016.html

So, attributes do not cascade and I have to push them down
to the nested tiles.

Looking at the syntax on that page, I took a look at
the tiles:putAttribute tag but I cannot figure out
how to do it.

Can someone please help me?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Neil Aggarwal [mailto:neil@jammconsulting.com] 
Sent: Monday, July 30, 2007 4:02 PM
To: users@tiles.apache.org
Subject: Nesting tiles 3 levels deep not finding attribute

Hello:

I have 3 levels of nested tiles:

  <definition name="layout" template="/layout.jsp">
    <put-attribute name="top" value="/top.jsp" />
    <put-attribute name="banner" value="/banner.jsp" />
    <put-attribute name="footer" value="/footer.jsp" />
  </definition>

  <definition name="product.nav" template="/productNavLayout.jsp">
    <put-attribute name="productPathNav" value="/productPathNav.jsp" />
    <put-attribute name="productNav" value="/productNav.jsp" />
  </definition>

  <definition name="product.grid" template="/productGridLayout.jsp">
    <put-attribute name="productGridTopNav" value="/productGridTopNav.jsp"
/>
    <put-attribute name="productGrid" value="/productGrid.jsp" />
    <put-attribute name="productGridBottomNav"
value="/productGridBottomNav.jsp" />
  </definition>

  <definition name="page.products" extends="layout">
    <put-attribute name="content" value="product.nav" />
    <put-attribute name="productContent" value="product.grid" />
  </definition>

For some reason, when I load the page.products definition, I
get this error:

javax.servlet.jsp.JspException: Error executing tag: Attribute
'productContent' not found.
        at
org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagS
upport.java:80)
        at
org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport
.java:80)
        at
org.apache.jsp.productNavLayout_jsp._jspx_meth_tiles_005finsertAttribute_005
f2(productNavLayout_jsp.java:170)

But, as you can see, the page.products definition defines productContent
directly.

Any ides what is going on here?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.