Hi All (esp. Antonio),

I'm having a problem passing an attribute from a Tiles definition into a layout page.
This is something which works for me using Tiles 2.06 on Tomcat 6.0.20,
but is failing using Tiles 2.07 on Google App Engine.

Here is my stripped-down example. The target browser page will be
                         testa.jsp
The desired goal is to pass the "pagename" attribute from tiles- defs.xml to testLayout.jsp: {And the real goal is to get that parameter value passed into the Javascript for the page.}

testa.jsp
=============

<%@ page contentType="text/html;charset=UTF-8" language="java" session="false" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles"; prefix="tiles" %>

<tiles:insertDefinition name="test.testa" />
------------

testLayout.jsp
==============
<%@ page contentType="text/html;charset=UTF-8" language="java" session="false" %>
<%...@page import="java.net.URLDecoder"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles"; prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt"; prefix="c" %>

<tiles:importAttribute name="pagename" /> <<<<<<< Tiles import here

<!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="page_title"/></title>
</head>
        
<script type='text/javascript'>
function pageinit(whatpage){
        alert("pageinit: "+whatpage);
}
</script>
</head>

<body onload="pageinit('${pagename}');"> <<<<<<<<<< Evaluate import here
<h1><tiles:getAsString name="page_title"/></h1>
  layout stuff....
</body>
</html>
------------

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="test.common"         template="/layouts/testLayout.jsp">
    <put-attribute name="footer"    value="/tiles/myfooter.jsp" />
    <put-attribute name="pagename"  value="defaultpage" />
</definition>

<definition name="test.testa"         extends="test.common">
<put-attribute name="pagename" value="test.atesta" /> <<<<< Attribute value originates here
    <put-attribute name="page_title"  value="Test TestA" />
</definition>

</tiles-definitions>
------------

I expect to see the Javascript alert showing:
                        pageinit: test.testa

However, I only get
                        pageinit: ${pagename}

The complete generated page source for testa.jsp is:

=============
<!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>Test TestA</title>

</head>
        
<script type='text/javascript'>
function pageinit(whatpage){
        alert("pageinit: "+whatpage);
}
</script>
</head>

<body onload="pageinit('${pagename}');">
<h1>Test TestA</h1>
  layout stuff....
</body>
</html>
------------

I have the standard.jar and jstl.jar jars on the classpath. I / thought/ that and Tiles was all I used in the Tiles 2.06 + Tomcat project where this works. I'm probably missing something, but I don't see what.

Any pointers/thoughts on what I've missed will be greating appreciated.
Thanks in advance,
Ken Bowen


Reply via email to