Back Forum Reply New

Another problem with tiles.

I am following the example from the book I have bought on how to implement Tiles in a Spring application (I removed all reference of FreeMarker for now).

Now this seems to partially be working, but not completely.  So I have a default.ftl page inside the WEB-INF/tiles folder.  I then created two other pages in the same folder called body.ftl and header.ftl.

I have a controller class names IntroController, this returns a new Model(“intro”, “message”, “hello”).

Now my tiles configuration is as follows:Code:
lt;definition name=quot;templatequot; page=quot;/WEB-INF/pages/default.ftlquot;gt;
lt;put name=quot;titlequot; value=quot;Default titlequot;/gt;
lt;put name=quot;headerquot; value=quot;=quot;/WEB-INF/pages/header.ftl quot;/gt;
lt;put name=quot;contentquot; value=quot;/WEB-INF/pages/intro.ftlquot;/gt;
lt;/definitiongt;

lt;definition name=quot;introquot; extends=quot;templatequot;gt;
lt;put name=quot;contentquot; value=quot;/WEB-INF/pages/intro.ftlquot;/gt;
lt;/definitiongt;
My default page is as follows:Code:
lt;%@ taglib prefix=quot;tilesquot; uri=quot;/WEB-INF/lib/tiles/tiles.tldquot; %gt;

lt;htmlgt;
lt;headgt;
lt;titlegt;
lt;tiles:getAsString name=quot;titlequot;/gt;
lt;/titlegt;
lt;/headgt;
lt;bodygt;
Testing!
lt;tiles:insert name=quot;headerquot;/gt;
lt;tiles:insert name=quot;contentquot;/gt;lt;tiles:insert name=quot;footerquot;/gt;
lt;/bodygt;
lt;/htmlgt;
The intro.ftl file only has written “Body” in it, and the header.ftl file only has “Header” in it (very simple).

Now I configured my tiles as follows in the application-servlet.xml:Code:
lt;bean id=quot;viewResolverquot;
class=quot;org..web.servlet.view.InternalResourceViewResolverquot;gt;

lt;property name=quot;viewClassquot;gt;
lt;valuegt;
org..web.servlet.view.tiles.TilesView
lt;/valuegt;
lt;/propertygt;
lt;/beangt;

lt;bean id=quot;tilesConfigurerquot;

class=quot;org..web.servlet.view.tiles.TilesConfigurerquot;gt;

lt;property name=quot;definitionsquot;gt;
lt;listgt;
lt;valuegt;/WEB-INF/tiles-defs.xmllt;/valuegt;
lt;/listgt;
lt;/propertygt;
lt;/beangt;
So as you can see from the above code I am not doing anything big.  Now when I call my application I enter the ucl application/intro.htm.  This goes in the IntroController which return the new ModelAndView.  Since I have the tiles configuration the result goes to the definition with the name “intro”, this extends “template” so it goes up there and loads the page quot;/WEB-INF/pages/default.ftlquot;.  

This works fine, since this is the page I am getting, however on the screen I only have ‘Testing’ written (no ‘Header’ or ‘Body’).  Also the title is set to ‘lt;tiles:getAsString name=quot;titlequot;/gt;’ and not ‘Default title’!

I went to see the source, and what I noticed is that what is happening is that the lt;tiles:insert . . . gt; and lt;tiles:getAsString . . . gt; are not being replaced.

I can not understand why this is happening, am not an expert in tiles, however I know I followed the book example till the last, even tried creating a control for the header section!

I am reading the other manning book struts in action the chapter related with tiles, but so far to no avail

Thanks for any help and suggestions,
Regards,
Sim085
¥
Back Forum Reply New