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

前端 未结 2 1913
南方客
南方客 2021-02-09 10:58

I want to know how to remove a tile from a view. My main view is looking like this

\"Main

相关标签:
2条回答
  • 2021-02-09 11:36

    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>
    
    0 讨论(0)
  • 2021-02-09 11:49

    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.

    0 讨论(0)
提交回复
热议问题