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 <[EMAIL PROTECTED]>:
>>
>>
>> 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.