Views

With Waffle you can write views with either Java Server Pages (JSP), FreeMarker or Velocity. Other view technologies, like Tiles or Sitemesh are compatible with Waffle (eg cf our Freemarker example).

Java Server Pages

Using Java Server Pages in Waffle is as easy as it is with other frameworks. You'll be able to reference the Controller that is asscoaiated with the view by the controller keyword. In the jspx example below the getName() method will be invoked from the Controller:

You will also need to set the default view suffix parameter on the WaffleServlet so that actions can be routed to the correct view. The following is an exerpt from the web.xml file:

Note that all view configuration init-params are optional, (and this is why they are left out in some of our examples).

FreeMarker

FreeMarker views can be written like any FreeMarker pages for other web frameworks. For the most part it is best to follow the documentation FreeMarker provides. Similarly to the JavaServer Pages definition above you will need to register the default view suffix accordingly for FreeMarker (typically .ftl).

You will need to register the freemarker.ext.servlet.FreemarkerServlet (or com.opensymphony.module.sitemesh.freemarker.FreemarkerDecoratorServlet if using in conjunction with SiteMesh) in the web.xml:

Again, see our working Freemarker example.

Velocity

As with the JavaServer Pages and FreeMarker descriptions above you can access the actions from your Velocity script via the action keyword. The example below shows how you should register the Servlet to handle Velocity based pages: