I'll try and explain my best.
I want to have a master-layout that has a head and a body (attributes,
or decorated content). These attributes, head and body, are also
templates that have attributes (decorated content).
I can invoke main.layout, but I don't know how to set the pageCSS, et c.
tiles-defs.xml
<definition name="main.layout " template="/tiles/main-layout.jsp">
<put-attribute name="head" value="head.content"/>
<put-attribute name="content" value=" body.content"/>
<put-attribute name="body" value="body.content"/>
<put-attribute name="title" />
<put-attribute name="pageCSS"/>
<put-attribute name="pageJS"/>
</definition>
<!-- Used by the main layout -->
<definition name="head.content" template="/tiles/head-content.jsp">
<put-attribute name="title" value=""/>
<put-attribute name="pageCSS" value=""/>
<put-attribute name="pageJS" value=""/>
</definition>
<!-- Used by the main layout -->
<definition name=" body.content">
<put-attribute name="content" value="/index-content.jsp"/>
</definition>
</tiles-definitions>
main-layout.jsp
<%@ taglib uri="http://tiles.apache.org/ta gs-tiles" prefix="tiles" %>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd">
<html>
<head>
<%-- Template "head" will have attributes:
title
pageCSS
pageJS
--%>
<tiles:insertAttribute name="head">
<tiles:importAttribute name="title" value="title" />
<tiles:importAttribute name="pageCSS" value="pageCSS" />
<tiles:importAttribute name="pageCSS" value="pageCSS" />
</tiles:insertAttribute>
</head>
<body>
<tiles:insertAttribute name="body">
<div id="contents">
<tiles :putAttribute name="footer" />
<jsp:include page="/news/index.html"/>
<tiles:insertAttribute name="footer" />
</div>
</tiles:insertAttribute>
</body>
</html>
index.jsp:
<%@ taglib uri=" http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="main.layout">
<tiles:putAttribute name="pageCSS" value="/res/css/pages/index.css" />
</tiles:insertDefinition>
The result:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<link rel="shortcut icon" href='/favicon.ico' />
<link rel="Stylesheet" href="/res/skins/1.css" />
<script src="/res/js/utils.js" type="text/javascript"></script>
<script src="/res/js/treeparams.js" type="text/javascript"></script>
<script src="/res/js/AnimTree.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
What happened to the index.css file that I invoked in index.jsp (using
<tiles :putAttribute name="pageCSS")? The value is a valid URL -- I
checked it in the browser.
I just don't know how to do it!
Please advise.
Thank you,
Garrett