tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brian f <flanag...@gsicommerce.com>
Subject Newbie issue with insertAttribute
Date Tue, 15 Sep 2009 16:56:00 GMT

Hi all, brand new to templating in general and Tiles 2.  I've followed
through the tutorials on the Apache site and, after a bit of wrangling,
managed to get the Tiles lib working in Tomcat (version 6).  I'm stuck on
one last issue though: when I define an attribute inside of a definition
with a url string as the value, I can't seem to have it properly interpreted
during render to the page.  Instead of getting the contents of the url page,
I'm seeing the actual url string itself.

Here's my setup:

WEB-INF/tiles-defs.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
	<tiles-definitions>
		<definition name="myapp.homepage"
template="../tiles/pageTemplates/main.jsp">
			<put-attribute name="banner" value="../tiles/pageTemplates/banner.jsp" />
			<put-attribute name="pageTitle" value="Tiles"/>
			<put-attribute name="bodyContent" value="body content"/>
		</definition>
	</tiles-definitions>

../tiles/pageTemplates/main.jsp
<%@ 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=UTF-8">
	<title><tiles:getAsString name="pageTitle"/></title>
</head>
<body>
	<tiles:insertAttribute name="banner"/><br />
	<tiles:getAsString name="bodyContent"/><br />
	<tiles:insertTemplate template="/tiles/pageTemplates/banner.jsp" />
</body>
</html>

tiles/index.jsp
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="myapp.homepage" />


/tiles/pageTemplates/banner.jsp
banner


When I load up tiles/index.jsp in my browser, here's what gets displayed:
../tiles/pageTemplates/banner.jsp
body content
banner 

I had hoped that the <tiles:insertAttribute name="banner"/> line would
output the contents of banner.jsp, but instead it outputs the value of the
attribute (in this case, the url).  I'm not sure what I'm doing wrong here. 
If I use the insertTemplate, I get the properly interpreted file rendered
out to the page.  Am I missing something...?
-- 
View this message in context: http://www.nabble.com/Newbie-issue-with-insertAttribute-tp25457736p25457736.html
Sent from the tiles users mailing list archive at Nabble.com.


Mime
View raw message