How to use Tiles with WebWork
This evening, I created a TilesResult for WebWork that allows you to use Tiles with WebWork. For the following to work in your application, you'll need a nightly build of Tiles, commons-digester (which Tiles requires) and this patch for WebWork. For your convenience, I've posted a patched webwork-2.2.2.jar (with TilesResult).
I also posted a webwork-tiles.war that you can try and download yourself. It's based on Equinox, so you will need to setup PostgreSQL and an "equinox" database - or you can just change the database settings in WEB-INF/lib/jdbc.properties.
On to the instructions:
1. In your web.xml file, you need to add a servlet entry for TilesServlet to load the tiles definitions into the ServletContext.
<servlet> <servlet-name>tiles</servlet-name> <servlet-class>org.apache.tiles.servlets.TilesServlet</servlet-class> <init-param> <param-name>definitions-config</param-name> <param-value>/WEB-INF/tiles-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
2. In xwork.xml, use type="tiles" on your <result>.
<action name="editUser" class="userAction" method="edit"> <result name="success" type="tiles">userForm</result> <result name="input" type="tiles">userList</result> </action>
I'm sure WebWork has a way of making this result type the default, I just haven't found it yet.
Hat tip to Spring's TilesView (source) for showing how to make this work.
Update: While I'm a happy SiteMesh user, I've recently had some clients who were more interested in Tiles. This largely inspired me to see if WebWork + Tiles was possible.
Update 2: It looks like TilesResult will be included in WebWork 2.2.2. Now if we could just get the Tiles team to cut a release.
<result-types>
<result-type name="tiles" class="com.opensymphony.webwork.views.tiles.TilesResult" default="true" />
</result-types>
Posted by Eric Hauser on February 16, 2006 at 01:28 PM MST #
Posted by Sanjiv Jivan on February 16, 2006 at 04:50 PM MST #
Posted by Sanjiv Jivan on February 16, 2006 at 04:52 PM MST #