Migrating from Tiles to SiteMesh in AppFuse 1.5

In this blog I explain how I’ve migrated from Struts Tiles to SiteMesh in a AppFuse 1.5 project. I wanted to do that because I was fedup of dealing with Tiles aliases and also because I’ve used SiteMesh in other projects and it’s really easy to use.



In %ROOT%metadatawebfilter-mappings.xml add the folowing

<!-- These are needed by Tomcat 5 for forwards -->



And in the filters.xml file add.



Change all the actions parameter from Tiles to path to JSP pages. For example, change from

<action path="/login" type="org.apache.struts.actions.ForwardAction"


<action path="/login" type="org.apache.struts.actions.ForwardAction"


In the %ROOT%metadatawebstruts-plugins.xml delete the reference to Tiles plugin

<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-config.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />

Action source code

The most painful job is to change all your xDoclet tags so that actions forward to a page and not a tile. So you have to change all action classes that are in %ROOT%srcwebmyappwebappaction for example, refering to your tiles-config.xml, change

@struts.action-forward name="architectures" path=".architectures"


@struts.action-forward name="architectures" path="/WEB-INF/pages/architectures.jsp"

The other problem that you may find is if you have used tiles.Controller. If yes, just change them to struts actions.


First, change your %ROOT%webcommontaglibs.jsp file. Delete

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

and add

<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page"%>

Layout to decorator

You have to copy and rename the Tiles layout from %ROOT%weblayoutsbaseLayout.jsp to the SiteMesh decorator %ROOT%webdecoratorsdefault.jsp. Once it’s done, change

<tiles:insert attribute="footer"/>


<c:import url="/common/footer.jsp"/>

If your baseLayout.jsp uses struts actions to display headers or footers, import the action. For example change

<tiles:insert attribute="leftMenu"/>


<c:import url="/loadLeftColumn.html"/>


Change the viewResolver in %ROOT%webWEB-INFaction-servlet.xml from

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="requestContextAttribute">
<property name="viewClass">



<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="requestContextAttribute" value="rc"/>
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>

<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>

Delete %ROOT%webWEB-INFapplicationContext-tiles.xml and tiles-config.xml. And instead add the new decorator.xml file:

<decorators defaultdir="/decorators">

<decorator name="default" page="default.jsp">


As well as the sitemesh.xml file

<property name="decorators-file" value="/WEB-INF/decorators.xml"/>
<excludes file="${decorators-file}"/>

<parser default="true" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser"/>
<parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser"/>
<parser content-type="text/html;charset=ISO-8859-1" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser"/>

<mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
<param name="config" value="${decorators-file}"/>


The two error pages 403.jsp and 404.jsp should be replaced by the new AppFuse ones.

Last but not least, in the %ROOT%build.xml file add the sitemesh.jar into the package-web task. And of course add the sitemesh.jar into the %ROOT%lib directory and update lib.properties file.

Should be ok now. Good luck.

Categories: Java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s