You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <zo...@holoweb.net> on 2004/03/16 01:31:24 UTC
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Using tiles
Posted by Laurie Harper <zo...@holoweb.net>.
Awsome, that did the trick! I'm getting an IllegalArgumentException if
the view name specified in struts-conf.xml doesn't start with a '/' but
I can live with putting the '/' in :-)
L.
David Friedman wrote:
> Dear Laurie,
>
> You forgot to set a page in your tile definition with the path attribute.
> The definition needs to be more like so:
>
> <definition name="tiles.view" path="/tiles-test/template.jsp">
> <put name="title" value="PAGE TITLE"/>
> <put name="content" value="/tiles-test/index.jsp"/>
> </definition>
>
> Where /tiles-test/template.jsp could look like:
>
> <%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>
> <html>
> <head>
> <title>
> <!-- insert the "title" attribute from your definition as a string -->
> <tiles:getAsString name="title" />
> </title>
> </head>
> <body>
> <!-- insert the "content" attribute from your definition as a parsed JSP
> page -->
> <tiles:insert attribute="content">
> </body>
> </html>
>
> Regards,
> David
>
> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Laurie Harper
> Sent: Monday, March 15, 2004 7:31 PM
> To: struts-user@jakarta.apache.org
> 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: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Using tiles
Posted by David Friedman <hu...@ix.netcom.com>.
Dear Laurie,
You forgot to set a page in your tile definition with the path attribute.
The definition needs to be more like so:
<definition name="tiles.view" path="/tiles-test/template.jsp">
<put name="title" value="PAGE TITLE"/>
<put name="content" value="/tiles-test/index.jsp"/>
</definition>
Where /tiles-test/template.jsp could look like:
<%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>
<html>
<head>
<title>
<!-- insert the "title" attribute from your definition as a string -->
<tiles:getAsString name="title" />
</title>
</head>
<body>
<!-- insert the "content" attribute from your definition as a parsed JSP
page -->
<tiles:insert attribute="content">
</body>
</html>
Regards,
David
-----Original Message-----
From: news [mailto:news@sea.gmane.org]On Behalf Of Laurie Harper
Sent: Monday, March 15, 2004 7:31 PM
To: struts-user@jakarta.apache.org
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org