You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Amit Rana <am...@gmail.com> on 2007/11/06 12:35:12 UTC
Problem with Tiles decoration and struts2
Hi,
I am trying to get TilesDecorationFilter
(http://tiles.apache.org/tutorial/advanced/utils.html) to work with
struts2.0.9 without any success. Can anyone please help me figure out
where am I going wrong? I am not sure if this is a tiles list question
or struts?
Tiles is decorating jsps but not the out put from an action.
If I access jsp/home.jsp it comes with the layout but home.action
only prints layout and result of action is not seen anywhere. There
are no errors. Kindly advice.
web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>MyApp</display-name>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter>
<filter-name>tilesdecoration</filter-name>
<filter-class>org.apache.tiles.web.util.TilesDecorationFilter</filter-class>
<init-param>
<param-name>definition</param-name>
<param-value>blank</param-value>
</init-param>
<init-param>
<param-name>attribute-name</param-name>
<param-value>body</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>tilesdecoration</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>home.action</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<struts>
<package name="default" extends="struts-default">
<result-types>
<result-type class="org.apache.struts2.views.tiles.TilesResult"
name="tiles">
</result-type>
</result-types>
<action name="home" class="com.tj.actions.HomeAction">
<result>jsp/home.jsp</result>
</action>
</package>
</struts>
tiles.xml
<?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="blank" template="/jsp/template/blankLayout.jsp">
<put-attribute name="title" value="my application" />
</definition>
</tiles-definitions>
blankLayout.jsp
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<html>
<head>
<title><tiles:getAsString name="title"/></title>
</head>
<body>
<tiles:insertAttribute name="body" />
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with Tiles decoration and struts2
Posted by Ghislain VANDERPOTTE <gh...@gmail.com>.
Oups, and I forgot the fact that the result has to be defined in the
tiles.xml file, it will not work by just adding the result type.
--
Ghislain
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with Tiles decoration and struts2
Posted by Ghislain VANDERPOTTE <gh...@gmail.com>.
Hi,
by quickly looking at your struts.xml, it seems that the result type misses:
<action name="home" class="com.tj.actions.HomeAction">
<result type="tiles">jsp/home.jsp</result>
^^^^^^^^^^^^^
</action>
I think it should now work
Cheers
Ghislain
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with Tiles decoration and struts2
Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/6, Amit Rana <am...@gmail.com>:
>
> I am trying to get TilesDecorationFilter
> (http://tiles.apache.org/tutorial/advanced/utils.html) to work with
> struts2.0.9 without any success. Can anyone please help me figure out
> where am I going wrong? I am not sure if this is a tiles list question
> or struts?
>
> Tiles is decorating jsps but not the out put from an action.
>
> If I access jsp/home.jsp it comes with the layout but home.action
> only prints layout and result of action is not seen anywhere. There
> are no errors. Kindly advice.
I suppose that it is a Tiles issue.
I must admit that the code inside the TilesDecorationFilter does not
convince me... Amit, can you repost this question to the Tiles Users Mailing
list? I think that it is a Tiles bug.
http://tiles.apache.org/mail.html
Thanks
Antonio
Re: Problem with Tiles decoration and struts2
Posted by Raghuveer Rawat <ra...@gmail.com>.
Amit,
looks like problem is with your struts.xml. You have set Tiles Result but
your result is jsp page. I think you need to change it to tile definition.
Try below...
struts.xml
<struts>
<package name="default" extends="struts-default">
<result-types>
<result-type class="
org.apache.struts2.views.tiles.TilesResult"
name="tiles">
</result-type>
</result-types>
<action name="home" class="com.tj.actions.HomeAction">
<result> *home*</result>
</action>
</package>
</struts>
tiles.xml
<?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="blank" template="/jsp/template/blankLayout.jsp">
<put-attribute name="title" value="my application" />
</definition>
<definition name="home" extends="blank">
<put-attribute name="title" value="my application" />
<put-attribute name="body" value="jsp/home.jsp" />
</definition>
</tiles-definitions>
On Nov 6, 2007 6:35 AM, Amit Rana <am...@gmail.com> wrote:
> Hi,
>
> I am trying to get TilesDecorationFilter
> ( http://tiles.apache.org/tutorial/advanced/utils.html) to work with
> struts2.0.9 without any success. Can anyone please help me figure out
> where am I going wrong? I am not sure if this is a tiles list question
> or struts?
>
> Tiles is decorating jsps but not the out put from an action.
>
> If I access jsp/home.jsp it comes with the layout but home.action
> only prints layout and result of action is not seen anywhere. There
> are no errors. Kindly advice.
>
> web.xml
> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns=" http://java.sun.com/xml/ns/javaee"
> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> id="WebApp_ID" version="2.5">
> <display-name>MyApp</display-name>
>
> <listener>
> <listener-class>
> org.apache.struts2.tiles.StrutsTilesListener
> </listener-class>
> </listener>
> <filter>
> <filter-name>struts2</filter-name>
> <filter-class>
> org.apache.struts2.dispatcher.FilterDispatcher
> </filter-class>
> </filter>
> <filter>
> <filter-name>tilesdecoration</filter-name>
> <filter-class>
> org.apache.tiles.web.util.TilesDecorationFilter</filter-class>
> <init-param>
> <param-name>definition</param-name>
> <param-value>blank</param-value>
> </init-param>
> <init-param>
> <param-name>attribute-name</param-name>
> <param-value>body</param-value>
> </init-param>
> </filter>
> <filter-mapping>
> <filter-name>struts2</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <filter-mapping>
> <filter-name>tilesdecoration</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <welcome-file-list>
> <welcome-file>home.action</welcome-file>
> </welcome-file-list>
> </web-app>
>
> struts.xml
> <struts>
> <package name="default" extends="struts-default">
> <result-types>
> <result-type class="
> org.apache.struts2.views.tiles.TilesResult"
> name="tiles">
> </result-type>
> </result-types>
> <action name="home" class=" com.tj.actions.HomeAction">
> <result>jsp/home.jsp</result>
> </action>
> </package>
> </struts>
>
> tiles.xml
> <?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="blank" template="/jsp/template/blankLayout.jsp">
> <put-attribute name="title" value="my application" />
> </definition>
> </tiles-definitions>
>
> blankLayout.jsp
> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
> <html>
> <head>
> <title><tiles:getAsString name="title"/></title>
> </head>
> <body>
> <tiles:insertAttribute name="body" />
> </body>
> </html>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>