Matt RaibleMatt Raible is a Java Champion and Developer Advocate at Okta. developer.okta.com

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

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.

Posted in Java at Feb 16 2006, 01:08:42 AM MST 3 Comments
Comments:

You can do this at a per package level or globally for the entire app:

<result-types>
&nbsp;&nbsp;<result-type name="tiles" class="com.opensymphony.webwork.views.tiles.TilesResult" default="true" />
</result-types>

Posted by Eric Hauser on February 16, 2006 at 07:28 AM MST #

What was the motivation behind using Tiles with WebWork. I thought you were a happy Sitemesh user like a lot of us.

Posted by Sanjiv Jivan on February 16, 2006 at 10:50 AM MST #

ugg, nevermind. I missed your previous blog entry.

Posted by Sanjiv Jivan on February 16, 2006 at 10:52 AM MST #

Post a Comment:
  • HTML Syntax: Allowed