I can now answer my own question regarding Struts2/Tiles2. I hope this information helps someone else.

I frankly have little grasp of the relationship between S2 and T2, but this information here works for me. If anything is incorrect or misleading I would love to know about it.

This information applies to Struts 2.0.6. This version is only compatible with whatever version of tiles is included. As is stated in many places, it does not work with the current latest version of Tiles, 2.0.3.

So, if you are trying to use Tiles 2.0.3 or later...don't read the rest of this message.

In your web.xml you will need a section like this:
   <listener>
       <listener-class>
           org.apache.struts2.tiles.StrutsTilesListener
       </listener-class>
   </listener>

In the same directory you need a file called tiles.xml (I'm not sure how this is found...I saw someone else who has a file called tiles-defs.xml) THIS IS IMPORTANT: Use the DTD below regardless of what you see in other documentation.

Notice the use of "put" and not "put-attribute" that you may have seen elsewhere.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
      "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
      "http://struts.apache.org/dtds/tiles-config_2_0.dtd";>

<tiles-definitions>

       <definition name="homeTiles" template="/layout/layout.jsp">
         <put name="title" value="Home"/>
         <put name="header"  value="/test/header.jsp" />
         <put name="menu" value="/test/menu.jsp"/>
         <put name="body" value="/test/home.jsp"/>
         <put name="footer" value="/test/footer.jsp"/>
       </definition>

</tiles-definitions>

And in layout.jsp use:

<%@ taglib uri="http://tiles.apache.org/tags-tiles"; prefix="tiles"%>

Combined with statements like:

<tiles:insertAttribute name="header" />

Good luck.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to