You need to define the laytou of your pages? Did you define where Tiles
should put title and content? If not, he can't compose your page.
Take a look now in the path attribute.

     <definition name="tiles.view" path="myLayout.jsp">
         <put name="title" value="PAGE TITLE"/>
         <put name="content" value="/tiles-test/index.jsp"/>
     </definition>

The myLayout.jsp contents could be:

<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html>
<head>
<title><tiles:insert attribute="title" />
<body>
<tiles:insert attribute="content" />
</body>
</html>

Hope this helps.

JP





-----Original Message-----
From: Laurie Harper [mailto:[EMAIL PROTECTED]
Sent: terça-feira, 16 de março de 2004 00:31
To: [EMAIL PROTECTED]
Subject: Using tiles


This is a newbie question on using the Tiles with Struts (never tried it 
before). I followed the instructions in the first half of Tiles 101/201, 
linked from the Tiles documentation but am having no luck on the 
Struts/Tiles integration front. I suspect I've simply missed a step 
somewhere.

Here's what I've done:

* Ensured Tiles is enabled in struts-conf.xml (it was by default):
   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
     <set-property property="definitions-config"
                          value="/WEB-INF/conf/tiles-defs.xml" />
     <set-property property="moduleAware" value="true" />
     <set-property property="definitions-parser-validate" value="true" />
   </plug-in>

* added a tile definition to teils-defs.xml:
     <definition name="tiles.view">
         <put name="title" value="PAGE TITLE"/>
         <put name="content" value="/tiles-test/index.jsp"/>
     </definition>

* added an action mapping to struts-conf.xml pointing to the tile:
     <action path="/tiles"
             type="DummyTilesAction">
         <forward name="view" path="tiles.view"/>
     </action>

* created /tiles-test/index.jsp with some static text content

What I expected was that when I hit /tiles.do I'd get back the static 
content from /tiles-test/index.jsp. What I actually get back is the 
string '<html><body></body></html>', which I haven't defined anywhere.

I also tried implementing execute() in DummyTilesAction to do a 'return 
mappings.findForward("view");' but no luck. Changing the name of the 
view in struts-conf.xml or tiles-defs.xml makes no difference, and 
generates no error messages when they don't match, which makes me 
suspicious...

The tiles defs do seem to be read in on startup:

L4J 2004-03-15 19:22:47,801 DEBUG 
org.apache.struts.tiles.xmlDefinition.I18nFactorySet default 
factory:{tiles.layout.basic={name=tiles.layout.basic, 
path=/tiles.layout.basic.jsp, role=null, controller=null, 
controllerType=null, controllerInstance=null, attributes={title=DEFAULT 
TITLE, content=/tiles.content.default.jsp, 
menu=/tiles.layout.basic.menu.jsp}}
, tiles.view={name=tiles.view, path=null, role=null, controller=null, 
controllerType=null, controllerInstance=null, attributes={title=PAGE 
TITLE, content=/tiles-test/index.jsp}}
}
L4J 2004-03-15 19:22:48,065 DEBUG 
org.apache.struts.tiles.xmlDefinition.I18nFactorySet Factory initialized 
from file '/WEB-INF/conf/tiles-defs.xml'.
L4J 2004-03-15 19:22:48,065 INFO  org.apache.struts.tiles.TilesPlugin 
Tiles definition factory loaded for module ''.

and the action mapping was picked up correctly; when I hit /tiles.do I 
get this logged:

L4J 2004-03-15 19:25:49,791 DEBUG 
org.apache.struts.action.RequestProcessor  Looking for Action instance 
for class DummyTilesAction

But no Tiles related logging, and the page specified in the tile 
definition isn't loaded. The taglib documentation at 
http://jakarta.apache.org/struts/userGuide/struts-tiles.html says that I 
have to call initComponentDefinitions or otherwise arrange to have Tiles 
initialized. I thought the configuration in struts-conf.xml would make 
that happen, but tried calling the tag in case. That didn't seem to help.

What am I doing wrong? If I've left any information out, please ask and 
I'll post it.

Thanks,

L.



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

Reply via email to