You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Marcus Oenicke <m....@it4u-berlin.biz> on 2007/10/08 00:13:46 UTC

Re: Nesting tiles 3 levels deep not finding attribute

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 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