tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Woodroffe <dan.woodro...@gmail.com>
Subject Help propagating attribute from view to templates
Date Mon, 23 Jan 2012 22:19:59 GMT
Hi, I hoped somebody could help me, I think what I'm asking is pretty
basic but I haven't been able to get this configured correctly. I'd
like to prefix this question by saying I do not know Java, I'm a front
end dev working with an overstretched Java team.

We've encountered problems with Sitemesh and I'm attempting to replace
our dependancy on it with Tiles, as it looks far more useful. I've
followed the tutorials but cannot work out how to override attributes
on a per page basis.

I'm not sure of the correct terminology, but /location on our website
relates to /WEB-INF/jsp/location.jsp

This is what I have, I'm using Tiles 2.2, we've enabled MutableTileContainers:


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">
   <definition name="base.definition" template="/WEB-INF/jsp/layout.jsp">
       <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
       <put-attribute name="body" value="" />
   </definition>
   <definition name="location" extends="base.definition">
       <put-attribute name="body" value="/WEB-INF/jsp/location.jsp" />
   </definition>


layout.jsp

...
<tiles:putAttribute name="title" cascade="true" value="Layout Title" />
<tiles:insertAttribute name="header" />
<tiles:insertAttribute name="body" />
...


header.jsp

<tiles:getAsString name="title" />

location.jsp

...
<tiles:putAttribute name="title" cascade="true" value="Location Title" />
...



This displays 'Layout Title' as expected, however the presence of
<putAttribute name="title" ... /> in 'layout.jsp is purely to
illustrate my problem.. I wish to populate the 'title' attribute
within location.jsp. When I remove the putAttribute from layout,
expecting to see the title specified in 'location.jsp' to appear, the
application throws a 500 along the lines of 'cannot find attribute
title'.

I've verified that location.jsp is loading, but it seems the syntax I
am using is incorrect.

I'm fully aware that I could place this title in the xml configuration
for each page type, but there are multiple types of data I need to
perpetuate through from location.jsp to the layout.jsp (and
header.jsp), for example we have an in house jawr wrapper to achieve
deferred javascript load and execution that references different files
on a per page basis.

So, my question is, given the setup above, what is the syntax for
creating the title attribute in 'location.jsp' so that it is available
in 'header.jsp'

Many thanks for reading, hope you can help!

-- 
Email - dan.woodroffe@gmail.com
Telephone [UK] - +44 (0)208 1230888
Skype - danwoodroffe
MSN - dan.woodroffe@gmail.com

Mime
View raw message