How to leave a tile empty

Can I leave the tile blank? Say I have three tiles on a page: header, body, footer. Can I just add the body and footer and leave an empty header?

<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 time 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 then one day:

  <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 use is exploding. Saying that I did not define a headline.

Is there any way to do this?

+4
source share
2 answers

Use ignore attribute:

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

According to docs :

If this attribute is set to true and the attribute specified by the name does not exist, just go back without writing anything. The default value is false, which will throw a runtime exception.

+10
source

You can simply provide an empty header page in the base definition, and then replace the tags and footers with more specific ones.

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

 <put-attribute name="header" value=""/> 
+4
source

All Articles