RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Stripes 1.5 in Black and White: Simpler Java Web Development

The latest release of the Stripes MVC framework adds simplified configuration as well as support for security, AJAX, and more without forgetting its ease-of-use roots.

ne of the attributes that attracted me to the Stripes MVC framework was its ease of use and short learning curve. The latest release of Stripes, version 1.5, preserves this nature by enhancing many of its existing features without requiring extra work or adding complexity. This article highlights the main enhancements in Stripes 1.5, including simplified configuration and added support for security and AJAX. The accompanying code download is a simple contact-manager application .war file that demonstrates some of these enhancements.

Let's begin with Stripes 1.5's simpler configuration.

Smaller Configuration Footprint
This version of Stripes has reduced what was already a small configuration footprint. Now you can configure most applications with only two initialization parameters and a couple of filter and servlet mappings. The ActionResolver.Packages and Extension.Packages replace the ActionResolver.UrlFilters and ActionResolver.PackageFilters parameters. The new Extension.Packages parameter lets you place references to any custom extensions in your application, including the ActionBeanContext, formatters, converters, and exception handlers. (See Listing 1 for a Web.xml configuration.)

Improved Type Conversion
Version 1.5 also improves on Stripes' already strong type conversion capabilities. Now you can load formatters and type converters using autodiscovery, employing the Extensions.Packages mentioned above. Stripes' default formatter now supports inheritance and interfaces, and the DateTypeConverter for converting Java dates into HTML and vice versa has been made more robust.

Introducing Clean URLS
The Stripes team has added features that help you create cleaner, more compact URLs. Clean URLs is an advanced binding format for ActionBeans that allows you to embed events and parameters into the URL in a more compact manner than the classic CGI parameter=value pattern.

The following example shows how you can annotate an ActionBean to bind one or more parameter values, as well as an event name, to an ActionBean:

public class UserActionBean extends BaseActionBean {


The UrlBinding annotation associates the "action/User" path with an event, {$event}, and the contact.id parameter. A valid URL might look like this: http://myhost/action/User/view/12122.

You can then output that parameter value into URLs in your JSPs using the Stripes link and URL tags. Upon return to the ActionBean, the event will be used to route the request to the proper ActionBean resolution in the controller, while all parameters will be validated—if needed—and bound to their associated properties in the ActionBean. The corresponding Stripes link tag for the above example would look like this:

<stripes:link event="view" href="/action/User">
<stripes:param name="contact.id" value="${contact.id}"/>
${contact.lastName}, ${contact.firstName}

Author's Note: Check out Stripernate, a Stripes extension that helps bind a Hibernate EJB3 layer to Stripes, and Google Guicer for simple integration of Stripes ActionBean and ActionBeanContext objects.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date