---
title: Integrating VRaptor with Tiles 3
---
# Integrating VRaptor with Tiles 3
## by Otávio Garcia
Apache Tiles is a framework that implements the Composite View pattern, and makes possible to
create templates for your application in easy way. You can found more information visiting
Tiles website.
The first step is include the Tiles dependency in your Maven project as described below.
If you don't uses Maven, you can download all files and its dependencies in
Tiles website.
~~~
#!xml
org.apache.tiles
tiles-extras
3.0.0
~~~
And the next step is to add the listener that tells to Tiles when your application is up
and ready.
~~~
#!xml
org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
~~~
And for the last step, you need to declare the `Servlet` that will respond Tiles requests.
In the example below, any request to the URL `*.tiles` will be forwarded to Tiles templates.
~~~
#!xml
TilesDispatchServlet
org.apache.tiles.web.util.TilesDispatchServlet
TilesDispatchServlet
*.tiles
~~~
And now we have Tiles listening requests.
By default, VRaptor does forwards to JSPs. So we need to override this behavior to forward
to Tiles templates. We can do it changing the class `DefaultPathResolver` as described below.
~~~
#!java
@Specializes
public class TilesPathResolver extends DefaultPathResolver {
@Inject
protected TilesPathResolver(FormatResolver resolver) {
super(resolver);
}
@Override
protected String getPrefix() {
return "/";
}
@Override
protected String getExtension() {
return "tiles";
}
}
~~~
With this code, whether the request was initiated for method `CustomerController.form`, VRaptor
will forward to template `customer.form`. So we only need by now to create the template
definition in the file `/WEB-INF/tiles.xml`:
~~~
#!xml
[...]
~~~
Tiles has a older Javassist version as dependency, which might cause issues with the
one used by VRaptor. To resolve this situation, what should be done is exclude the dependency
as it is defined in the example below:
~~~
#!xml
org.apache.tiles
tiles-extras
3.0.0
javassist
jboss
~~~