Andrew Luca Andrew Luca - 1 year ago 76
HTML Question

How to achieve this layout using apache tiles 2?

enter image description here

Having problems creating such a layout. Controllers trigger dash content, and the layout should be created. Now I have this definitions, and I am blocked.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"


<definition name="masterLayout" template="/WEB-INF/jsp/layout/master.jsp">
<put-attribute name="headerInclude" value="" />
<put-attribute name="body" value="" />
<put-attribute name="footerInclude" value="" />

<definition name="dashboardLayout" extends="masterLayout">
<put-attribute name="body" value="dashboardLayoutBody" />

<definition name="dashboardLayoutBody" template="/WEB-INF/jsp/layout/dashboard.jsp">
<put-attribute name="menu" value="/WEB-INF/jsp/parts/menu.jsp" />
<put-attribute name="body"/>

<!-- this page is triggered -->
<definition name="login_page" extends="masterLayout">
<put-attribute name="body" value="/WEB-INF/jsp/layout/login.jsp" />

<!-- this page is triggered -->
<definition name="some_page" extends="dashboardLayout">
<put-attribute name="body" value="/WEB-INF/jsp/content/admin_groups/supervisor.jsp"/>


master layout has this content

<!DOCTYPE html>
<!-- Master css, js, meta, tags additions .... -->
<tiles:insertAttribute name="headerInclude"/>
<tiles:insertAttribute name="body"/>

<!-- Master css, js, meta, tags additions .... -->
<tiles:insertAttribute name="footerInclude"/>

I need somehow to extend template and also have own template, to include menu there

Answer Source

As a new comer to jsp templating, I didn't realized that I can use jsp:include in parallel with Aapache Tiles, which solved the problem.

The main problem was that I couldn't include the menu once only in the dashboard layout, and be used everywhere.

Using only tiles, there is cascade attribute on a put-attribute tag that allow that to be used in other attributes also.

Keep in mind that cascade needs DOCTYPE tiles-definition minimum version 2.1

<!DOCTYPE tiles-definitions PUBLIC
        "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download