1

I have one master template that has the general site layout frame: "/WEB-INF/jsp/common.jsp" Then I have another template that will be generally used for another number of pages with similar layout: "/WEB-INF/jsp/features/common.jsp"

The features template basically defines the content of attribute "content" of the "master" template.

I have tried to solve this the following way:

<definition name="product.common" template="/WEB-INF/jsp/common.jsp">
    <put-attribute name="content" value="/WEB-INF/jsp/features/common.jsp" />
</definition>
<definition name="features/index" extends="product.common">
    <put-attribute name="title" value="Features" />
    <put-attribute name="rightContent" value="/WEB-INF/jsp/features/index.jsp" />
</definition>

But this does not work. I get the following error message in my stack trace:

org.apache.tiles.template.NoSuchAttributeException: Attribute 'rightContent' not found.

But the features-template does have the following:

<tiles:insertAttribute name="rightContent" />

Any ideas?

Piotr
  • 4,813
  • 7
  • 35
  • 46

1 Answers1

1

I guess what you need is nesting definitions. You could try something like this.

<definition name="features.common" template="/WEB-INF/jsp/features/common.jsp">
</definition>

<definition name="product.common" template="/WEB-INF/jsp/common.jsp">
    <put-attribute name="content" value="features.common" />
</definition>

<definition name="features/index" extends="product.common">
    <put-attribute name="title" value="Features" />
    <put-attribute name="rightContent" value="/WEB-INF/jsp/features/index.jsp" />
</definition>
Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • How is that different from mine? – Piotr Mar 16 '11 at 12:03
  • @Piotr. If you look carefully, in my example, content holds a *subdefinition* value – Raghuram Mar 16 '11 at 12:14
  • Ok, I tried that and got "org.apache.tiles.template.NoSuchAttributeException: Attribute 'rightContent' not found. ". The problem is that "rightContent" is in the feature-common template. Any other ideas? – Piotr Mar 16 '11 at 13:06
  • The solution was to use cascading! :) Thanks for your help tho – Piotr Mar 16 '11 at 13:31
  • @Piotr. It'd be better if you add your answer to your question (even better if you point to an existing answer: [Propagating a Tiles attribute down the include chain](http://stackoverflow.com/a/4757812/413020)). The accepted answer, as you state, does not point into the right direction. – Alberto Jan 30 '12 at 19:46