[ 
https://issues.apache.org/jira/browse/WW-4161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058556#comment-14058556
 ] 

Lukasz Lenart edited comment on WW-4161 at 7/11/14 8:48 AM:
------------------------------------------------------------

You need a tiles.xml which defines a layout:

{code:xml|title=tiles.xml}
<tiles-definitions>
    <definition name=".default-layout" 
template="/WEB-INF/tiles/layout/layout.jsp">
        <put-attribute name="titleMsgKey" value=".titleMsgKey" />
        <put-attribute name="content" value=".content" />
    </definition>
    <!-- no more entries ! -->
    <!-- except you have several layouts -->
</tiles-definitions>
{code}


Then you can annotate actions. Annotations reference the layout and provide 
paramters:
{code:java|title=SampleAction}
@Result(name=SampleAction.INPUT, type="tiles-annotation")
@TileDef(
        extend=".default-layout",
        attributes={
                @TileAttribute(name="titleMsgKey", value="text.key.test"),
                @TileAttribute(name="content", 
value="/WEB-INF/tiles/test/test.jsp")
        }
)
public class SampleAction extends ActionSupport {
...
}
{code}

And an entry in web.xml is required:
{code:xml|title=web.xml}

<!-- a parameter for TilesListener is required which I wrapped in a specialized 
context listener -->
<!-- that parameter is:
                
<param-name>org.apache.tiles.factory.TilesContainerFactory.MUTABLE</param-name>
                <param-value>true</param-value>
-->
<listener>
                <listener-class>
                        org.apache.struts2.tiles.StrutsTilesAnnotationsListener
                </listener-class>
                <init-param>
                                
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
                                
<param-value>/WEB-INF/classes/tiles.xml</param-value>
                </init-param>
</listener>
{code}



was (Author: cn42):
You need a tiles.xml which defines a layout:

--------------------------------------------
tiles.xml
--------------------------------------------
<tiles-definitions>
    <definition name=".default-layout" 
template="/WEB-INF/tiles/layout/layout.jsp">
        <put-attribute name="titleMsgKey" value=".titleMsgKey" />
        <put-attribute name="content" value=".content" />
    </definition>

    <!-- no more entries ! -->
    <!-- except you have several layouts -->
</tiles-definitions>



Then you can annotate actions. Annotations reference the layout and provide 
paramters:
--------------------------------------------
SampleAction
--------------------------------------------
@Result(name=SampleAction.INPUT, type="tiles-annotation")
@TileDef(
        extend=".default-layout",
        attributes={
                @TileAttribute(name="titleMsgKey", value="text.key.test"),
                @TileAttribute(name="content", 
value="/WEB-INF/tiles/test/test.jsp")
        }
)
public class SampleAction extends ActionSupport {
...
}


And an entry in web.xml is required:
--------------------------------------------
web.xml
--------------------------------------------

<!-- a parameter for TilesListener is required which I wrapped in a specialized 
context listener -->
<!-- that parameter is:
                
<param-name>org.apache.tiles.factory.TilesContainerFactory.MUTABLE</param-name>
                <param-value>true</param-value>
-->
<listener>
                <listener-class>
                        org.apache.struts2.tiles.StrutsTilesAnnotationsListener
                </listener-class>
                <init-param>
                                
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
                                
<param-value>/WEB-INF/classes/tiles.xml</param-value>
                </init-param>
</listener>







> Incorporate tiles3 into conventions, tutorial (and add code to tiles3 plugin)
> -----------------------------------------------------------------------------
>
>                 Key: WW-4161
>                 URL: https://issues.apache.org/jira/browse/WW-4161
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Tiles
>            Reporter: Ken McWilliams
>             Fix For: 2.3.18
>
>         Attachments: struts2-tiles-annotations.patch, 
> struts2-tiles-annotations.patch
>
>
> There is a description found here: 
> http://stackoverflow.com/questions/11161194/freemarker-and-struts2-tags
> It would be good if the struts2 website could turn the following into a 
> tutorial, possibly some of the code could be included into the tile3 plugin 
> but I'm not convinced at this time that should be done. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to