Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to leave a tile empty

Is it possible to leave a tile empty? Let's say I have three tiles in a page: header, body, footer. Can i simply add a body and a footer and leave header empty?

<body class="claro">
<div id="wrapper">
    <div id="container" class="container">
    <div id="hd">
    <tiles:insertAttribute name="header" />
    </div>
    <div id="bd">
    <hr/>
    <tiles:insertAttribute name="body" />
    </div>
    <div id="ft">
    <hr/>
    <tiles:insertAttribute name="footer" />
    </div>
    </div>
</div>

So I want to use this once like this :

   <definition name="base" template="...">
    <put-attribute name="header" value="/WEB-INF/views/base/header.jspx" />
    <put-attribute name="body" value="/WEB-INF/views/base/body.jspx" />
    <put-attribute name="footer" value="/WEB-INF/views/base/footer.jspx" />
</definition>

And once like this :

 <definition name="base" template="...">
    <put-attribute name="body" value="/WEB-INF/views/base/body.jspx" />
    <put-attribute name="footer" value="/WEB-INF/views/base/footer.jspx" />
</definition>

Currently the second usage blows up. Saying i haven't defined header.

Is there a way to do this?

like image 912
Karthik Ramachandran Avatar asked May 06 '11 14:05

Karthik Ramachandran


2 Answers

Use the ignore attribute:

<tiles:insertAttribute name="header" ignore="true"/>

According to the docs:

If this attribute is set to true, and the attribute specified by the name does not exist, simply return without writing anything. The default value is false, which will cause a runtime exception to be thrown.

like image 142
David Avatar answered Sep 28 '22 04:09

David


You could just provide an empty header page in a base definition and then replace body and footer in the more specific ones.

You could also just set the value to an empty string:

<put-attribute name="header" value=""/>
like image 40
Thomas Avatar answered Sep 28 '22 06:09

Thomas