Hi all,
I'm using Tiles 2 with a Spring MVC 3 project I'm creating. I'm having a
bit of trouble getting attributes I want in to my pages. I have only 1
layout and 1 definition file, default.jsp and default.xml. I've included
the .jsp and xml below. I extend an existing spring class to dynamically
determine which page will be defined as the "body" definition. This works
well. However I want each of my body pages to define what the title will be
on the layout page. However, my variable is never picked up. Here is my
definition.
default.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="*/*" template="/WEB-INF/views/layouts/default.jsp">
<put-attribute name="title" value="Default Title"/>
<put-attribute name="header" value="/WEB-INF/views/tiles/header.jsp"
/>
<put-attribute name="menu" value="/WEB-INF/views/tiles/menu.jsp" />
<put-attribute name="footer" value="/WEB-INF/views/tiles/footer.jsp"
/>
</definition>
</tiles-definitions>
default.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><tiles:getAsString name="title" ignore="true"/></title>
</head>
<body>
<div id="content">
<div id="header"><tiles:insertAttribute name="header" />
<div id="menu"><tiles:insertAttribute name="menu" /></div>
</div>
<div id="body"><tiles:insertAttribute name="body" /></div>
<div id="footer"><tiles:insertAttribute name="footer" /></div>
</div>
</body>
</html>
Body page definition parts/edit.jsp
<c:set var="submit" value="Update Part"/>
<tiles:put name="title" type="string" value="Update Part" />
<h2>New Part</h2>
<%@ include file="/WEB-INF/views/parts/form.jsp" %>
My title "Update Part" never appears when the layout is rendered. What am I
doing wrong? Any help would be greatly appreciated.
Thanks,
Todd