You also need to add the following to struts.xml:
<result-types>
        <result-type name="tiles" 
class="org.apache.struts2.views.tiles.TilesResult" default="true"/>
</result-types>and then for some action foo:
<action name="foo" class="fooAction">
        <result name="success" type="tiles">test</result>
</action>

Then point to /foo.action



----- Original Message ----
From: Mansour <[EMAIL PROTECTED]>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Monday, May 14, 2007 9:59:41 PM
Subject: Re: Problems getting started with Tiles2/S2

I just tried it. I added this to tiles.xml

<tiles-definitions>

       <definition name="homeTiles" template="/pages/layout/layout.jsp">
         <put name="title" value="Home"/>
         <put name="header"  value="/pages/layout/header.jsp" />
       </definition>

    <definition name="test" extends="homeTiles">
         <put name="title" value="Test Title"/>
         <put name="body"  value="/pages/test.jsp" />
     </definition>

</tiles-definitions>

And pointed my browser to http://localhost:8080/ProjTiles/pages/test . I 
got error 404.

any idea


Shahak Nagiel wrote:
> 1) You do need to configure a tile for every page, but since tile definitions 
> use inheritance, it's not a big deal.  You just define what's unique to that 
> page (typically the page title and the body content, but can obviously be 
> other things as well).  Here's what you're missing:
>
> In tiles.xml:
> <tiles-definitions>
>
>        <definition name="homeTiles" template="/pages/layout/layout.jsp">
>          <put name="title" value="Home"/>
>          <put name="header"  value="/pages/layout/header.jsp" />
>             <put name="footer"  value="/pages/layout/footer.jsp" /> <!-- just 
> an example -->
>             <put name="nav"  value="/pages/layout/sideNav.jsp" /> <!-- just 
> an example -->
>        </definition>
>
>     <definition name="tile.TestPage" extends="homeTiles"> <!-- will 
> automatically inherit the attributes of 'homeTiles" -->
>
>          <put name="title" value="Test Title"/>
>
>          <put name="body"  value="/pages/test.jsp" />
>
>      </definition>
>
> </tiles-definitions>
>
>
> 2) Then, in struts.xml, instead of forwarding to /pages/test.jsp, forward to 
> "tile.TestPage" instead.  Presto.
>
>
> ----- Original Message ----
> From: Mansour <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <user@struts.apache.org>
> Sent: Monday, May 14, 2007 9:08:48 PM
> Subject: Re: Problems getting started with Tiles2/S2
>
> I followed every single step in this email. and couldn't get tiles to 
> work properly.
> I am not getting any error but the pages are displaying the way they are 
> with no header added. I am not sure how tile works but it seems to me 
> that I have to configure it for each single page which doesn't make 
> sense to me. Here's exactly what I did:
>
> in web.xml added :
>
>
> <listener>
>   
> <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
> </listener>
>
>
> In tiles.xml in the same directory as web.xml :
>
> <?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="/pages/layout/layout.jsp">
>          <put name="title" value="Home"/>
>          <put name="header"  value="/pages/layout/header.jsp" />
>        </definition>
>
> </tiles-definitions>
>
>
> in /pages/layout/layout.jsp :
>
> <%@ taglib uri="http://tiles.apache.org/tags-tiles";;; prefix="tiles"%>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <tiles:importAttribute name="title" scope="request"/>
> <html>
>     <head><title><tiles:getAsString name="title"/></title></head>
> <body>
>     <tiles:insertAttribute name="header"/>
>     <p id="body">
>     <tiles:insertAttribute name="body"/>
>     </p>
> </body>
> </html>
>
> in /pages/layout/header.jsp simply:
> This is a header for testing !
>
>
> and in my testing page /pages/test.jsp:
> <%@ taglib prefix="s" uri="/struts-tags" %>
> This is a testing page !
>
> What's going on ? can any one help?
>
>
>
>
>
>
> Rick Schumeyer wrote:
>   
>> 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]
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
>
>   


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





Reply via email to