Wednesday, February 22, 2006

Stripes - a lightweight web framework

During my continuing search for alternative web frameworks, I came across Stripes some time ago. It looked quite nice and has even gotten nicer with the recent release of version 1.2.

What I like about Stripes is that it is simple. It may not be the perfect web MVC framework capable of anything, but for most simple (and I don't mean simple as in trivial) web applications, it looks good.

Stripes has practically no external configuration. Most of the configuration (and not much is needed) is written as annotations in the ActionBeans (which, by the way, do not have to extend a specific base class). For instance, the @UrlBinding annotation on the class states the URL, the action is bound to. The @DefaultHandler annotation on a method specifies that this method should be invoked if a specific event has not been specified. The @HandlesEvent("eventName") registers a method that should be used to handle the eventName event. Of course, it does add a number of @annotation elements to your code, but due to the simplicity of the framework, it won't be so much, that it renders the code unreadable.

Stripes has the basic features you would expect from a modern web MVC framework (the items below are just a subset of the functionality. For the full list see the Stripes documentation):

  • Validation. There are a number of standard validators (annotation driven) and you may write your own validate method (which will be called if you implement the Validatable interface

  • Type conversion from HTML input elements to Java objects

  • AJAX support. There is built-in support for calling methods on ActionBeans from AJAX functions

  • Localization

  • Reuse of layouts. A templating mechanism allowing you to get a uniform layout without duplicating a lot of code

  • Integration with Spring. Adds the possibility to get dependencies injected into ActionBeans from the Spring context.

Version 1.2 has added a number of nice new features (among other things):

  • Wizard forms. Handling of the very typical usecase of wizard style dialogs.

  • Flash scope. The ability to support the redirect-after-post pattern while retaining the parameters from the post.

  • Smart defaults. A new feature in version 1.2 enables Stripes to automatically determine the URL bindings based on the class name and some default naming conventions

Stripes does not attempt to deliver lot of functionality outside of the core framework. There is no CRUD functionality, no support for sending mails etc. However, I don't see this as a negative thing - you might not need it.

One minor drawback is that Stripes requires Java 5, which may not be an option for you (if you use Websphere, for example). But then again, why not try to go with a simpler set-up in that respect too :-).

In conclusion, Stripes does seem to deliver on the functionality that is actually included. I'm really looking forward to see, how Stripes will progress in the future.