How to remove a tile in apache tiles for a specific view?

[亡魂溺海] 提交于 2019-12-03 07:28:41
Prabhakaran

In the Tiles.xml remove the header and footer value like below:

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

Then if you wants the only header and body:

<definition name="displayPageContent2" extends="base.definition">
  <put-attribute name="title" value="Employees List"></put-attribute>
  <put-attribute name="header" value="/WEB-INF/views/header.jsp" />"></put-attribute>
  <put-attribute name="body" value="/WEB-INF/views/content2.jsp"></put-attribute>
</definition>

I don't konw if that is what You expect, but You can always add in Your tiles config, a reference to an empty file (first create one) - so the menu will dissapear:

You can move menu td inside menu jsp, so the layout look simmilar to this:

<tr>        
<tiles:insertAttribute name="menu"></tiles:insertAttribute>
[...]
</tr>

Defs:

<definition name="displayPageContent1" extends="base.definition">
[...]
<put-attribute name="menu" value="/WEB-INF/views/empty.jsp"></put-attribute>    
</definition>

In the scenario given above, td with menu will not be presented, the same You can do for footer section.

Another way is to make a definition and nest it into another definietion, this will result in nested templates also, then You can insert those custom templates like this (example from other project):

<definition name="menu_template"  template="/WEB-INF/layouts/main_template/header.ftl">
<put-attribute name="SYSTEM_NAME_SHORT" value="SOL"/>
<put-attribute name="menu" value="/WEB-INF/views/menus/menu.ftl"/>
</definition>

<definition name="record.history" extends="main_template">
<put-attribute name="content" value="/WEB-INF/views/xxx.ftl"/>
<put-attribute name="header" >
<definition extends="menu_template">
<put-attribute name="menu" value="/WEB-INF/layouts/blank.ftl"/>
</definition>
</put-attribute>
</definition>

As You can see above, You can inject other templates into main template as attributes - in this case, menu template is inserted into attribute called header.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!