Reputation: 1280
I'm using Tiles 2.2 and I'd like to reuse a single JSP to display different messages. Messages have to be defined inside Tiles configuration file.
The following example is my approach: base is the base abstract definition all other definitions extend, while display would be an another abstract definition, used as a template for displaying messages. page1 and page2 are two final pages examples, each one displays a different message.
<definition name="base" template="layout.jspx"/>
<definition name="display" extends="base">
<put-attribute name="body" value="display.jspx"/>
</definition>
<definition name="page1" extends="display">
<put-attribute name="message" value="This is one message!"/>
</definition>
<definition name="page2" extends="display">
<put-attribute name="message" value="This is another message!"/>
</definition>
display.jspx would have something like this inside:
<tiles:useAttribute name="message"/>
Message: ${message}
But I couldn't make it to work, because when opening page1 or page2 I get an exception saying message attribute is null.
Is there an easy way to set up something like this, without modifying base template and definition?
Thanks in advance
Upvotes: 0
Views: 859
Reputation: 307
Probably too late, but I believe you need to add cascade="true"
to your put-attribute
elements for name="message"
.
Upvotes: 1