I have a Struts2 application: Struts version is 2.0.12 and Tiles is
2.0.4. Have also jars for commons-beanutil 1.8, digester 1.8, logging
1.04 and api 1.1.  IDE is MyEclipse Enterprise Workbench 6.5.1.

I have a "HelloWorld" action that calls a Tiles definition.  The
action (in struts.xml) is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd";>
<struts>
        <package name="default" extends="struts-default" namespace="/">
                <result-types>
                        <result-type name="tiles"
                                
class="org.apache.struts2.views.tiles.TilesResult" />
                </result-types>

                <action name="HelloWorld" 
class="org.rochesterDeltas.tutorial.HelloWorld">
                        <result type="tiles">MainPage</result>
                </action>

and the Tiles definition (in tiles.xml) is:

<?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="MainPage" template="WEB-INF/tiles/template.jsp">
        <put-attribute name="pageTitle" value="Test Template Page #4" />
        <put-attribute name="header" value="WEB-INF/tiles/header.jsp" />
        <put-attribute name="navigationOne" value="WEB-INF/tiles/menuOne.jsp" />
        <put-attribute name="body" value="WEB-INF/tiles/home_body.jsp" />
        <put-attribute name="footer" value="WEB-INF/tiles/footer.jsp" />
    </definition>
</tiles-definitions>

Here is the template.jsp (all jsp files are under  WEB-INF/tiles/:

<?xml version="1.0" encoding="UTF-8"?>
<%@ taglib uri = "http://tiles.apache.org/tags-tiles"; prefix="tiles"%>

<html>
<head>
        <title><tiles:getAsString name="pageTitle"/></title>
<style type="text/css">@import uri("../../delta.css");</style>
</head>

<body>
        <div id="bgcontain">
                <div id="container">
                        <div id="header">
          <tiles:getAsString name="header" />
                        </div>
                        <div id="leftwrap">
                        <div id="content">
          <tiles:insertAttribute name="body" />
                                        </div>
          <tiles:insertAttribute name="navigationOne" />
                        </div>
                        <div id="rightbar">
                        </div>
                </div>
                <div id="footer">
          <tiles:insertAttribute name="footer" />
                </div>
        </div>
</body>
</html>

When the action is called, it renders this page (with the correct text
in the title):

WEB-INF/tiles/header.jsp
WEB-INF/tiles/home_body.jsp
WEB-INF/tiles/menuOne.jsp
WEB-INF/tiles/footer.jsp

In other words, the template.jsp is being rendered, "getText is
working correctly, but, "insertAttribute" renders the path as a
string.  Can someone tell me where I'm wrong?


Bob

"If everyone is thinking alike, then, somebody isn't thinking! - George Patton

Reply via email to