Java Web Framework Sweet Spots
Java Web Framework Sweet Spots
Sweet Spots
Sponsored by
and
This document was compiled by asking a number of different Java web
framework authors the following questions:
RIFE
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
It’s a full-stack framework, which means that you get 90% of what all the others deliver with
10% of the effort. You also get it in a consistent fashion without having to figure out how
everything works together. We revisited a lot of the concepts in all the layers and re-designed
them with web application development in mind, offering unique features and new
approaches such as pure Java web continuations, run-time POJO-driven CRUD generation,
scalable component-oriented architecture, state handling without sessions, focus on REST as
an application API, bi-directional logicless template engine, and the integration of a content
management framework.
In addition, our component approach offers real reusability on every level (AOP, site, sub-
site, page, widget, portlet, etc.), not just for widget components.
I’d say that it’s very well suited for public web sites that are developed by a team of people
who want to deliver quickly, need to maintain the application over time, and are interested in
building up a collection of reusable web components.
Spring MVC aims to be a solid platform upon which developers can build without worrying
about on-going change. The number of features in Spring MVC to support i18n, file upload,
exception handling, and so on provides users with the confidence that they can choose
Spring MVC and know it will not let them down when the time comes to add more
complicated features to their applications
Best Practice
Encapsulates best practices and provides an ideal base on which to build applications whilst
not having to worry about doing things “the right way.”
Spring Integration
Builds on the core Spring Framework — doesn’t just stop at the web tier.
Support
The Spring community is large and active, providing developers with the means to obtain
the support they need. Organizations can buy commercial services from companies like
Interface21 to reduce the risk of adopting any new product.
Struts +1
Struts developers migrating to Spring MVC become more productive without having to
learn a new paradigm.
Project types
Developers using Spring Web Flow use it to orchestrate stateful tasks with a linear
progression.
Abstraction
Spring Web Flow abstracts a lot of common issues away from the user, such as conversation
state management, flow enforcement, and back button handling. This level of abstraction
allows developers to focus on the task at hand and not on the underlying plumbing.
Project types
Spring Web Flow is a specialized product focused on solving one problem really well. It
should be considered for the parts of a site that execute controlled navigations to complete
business tasks. SWF plugs in to Spring MVC, Struts, and JSF as a complement (an
embeddable task-execution engine addressing the “C” in MVC).
Spring MVC has Ajax support via the DWR library. We are constantly assessing what our
users want when it comes to Ajax in Spring MVC, and we will ensure that their needs are
met.
Spring Web Flow
• Rich configuration schema for configuring the flow-execution engine.
• Convention-based defaults for automatically exposing bean method return values to
view templates. For example, if SWF invokes the method “Collection
getPeople(SearchCriteria)” on the “Phonebook” service-layer facade, the returned
collection will be exposed to the view with the name “people”.
• Transparent variable resolution support for searching multiple namespaces to resolve a
flow-variable value. For example, instead of referencing a qualified method binding
expression: method=“placeOrder(${flowScope.order}))”, developers can simply write:
method=“placeOrder(${order}))”.
• View template support, including automatic bookmark-friendly flow URL generation
and a <spring:webflow> tag library.
• Data mapping enhancements to further abstract a flow definition from its execution
environment; for example, support for a declarative mapping of flow input attributes
from the request path.
• Transparent conversational component lifecycle management with the option of full
control over conversational state when needed (via a memento-based or an annotation-
based strategy).
• Monitoring in-progress conversations via JMX.
• Conversation history subsystem (to support breadcrumbs, automatic restart of expired
conversations).
• Packaged Hibernate and Acegi integration (long session per flow and flow-level security,
respectively).
• Additional integration with other frameworks.
• Additional samples demonstrating JSF integration in a component-rich environment.
• Patterns for implementing long-lived flows (that involve a durable store like a DB).
• Flow inheritance.
• Support for metadata-driven continuation invalidation to prevent backtracking once a
certain step of a flow is complete. For example, after a flow exits a “non-repeatable”
view-state, going back to any previous view state will be disallowed.
• Support for applying flexible flow input-mapping rules. For example, a REST-style
mapper might map the URL http:/localhost/phonebook/matt to a new execution of the
“phonebook” search flow, mapping the “name” input attribute from the request path.
This input attribute would be consumed consistently by the flow execution regardless of
whether it was launched by a browser via a top-level URL or spawned internally as a
subflow from another flow.
Regarding Ajax
Stripes
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
Stripes’ sweet spot is probably very similar to that of Spring MVC, WebWork, etc. While it
has some innovative functionality, one of Stripes’ biggest goals is to take the functionality of
a high-quality action-oriented framework and implement it in a way that is much simpler to
ramp up on — and much more productive in day-to-day development.
That said, one area where Stripes really shines is in applications with lots of complex data
interactions. Its type conversion, binding, and validation are very powerful and make it easy
to manage large, complex forms and map them directly to domain objects, etc.
2. What type of scenarios does it not fit in to? Would you
recommend another framework in this scenario? If so,
which one?
One area I can think of (and this is generally true for action-oriented frameworks) is for user
interfaces that are non-AJAX driven and involve several unrelated or loosely related stateful
components on the same page.
As an example, imagine a Google homepage where you could pop open multiple search
panels and search and page through results etc. in each panel. Each time you hit next on one
panel, the whole page would be refreshed, the panel you clicked on updated, and all the
other panels left as they were.
Managing a UI like this in a way that is multi-window safe can be very difficult. This is the
problem that component-oriented solutions like Wicket and JSF were designed to solve. My
view is that for 90%+ of web applications, component-oriented frameworks are overkill, and
that for another 9%, AJAX is more a more effective way to manage a stateful UI as
described above.
If I were in a situation in which I needed to develop such an application for a client and the
client didn’t want to use AJAX, I would probably look at Wicket. I’ve looked at Wicket
before (although not used it in anger) and am impressed with the quality and focus on
simplicity in the project.
2. Annotations mean you can have only one set of configurations. First, I have to believe
that 90%+ of actions have a single set of configuration! We’re talking about classes that are
built to service a specific web UI. However, Stripes has two ways out of this “one
configuration only” myth.
Stripes looks for annotations starting at a class’ most distant parent and comes down the
hierarchy. Annotations on child classes override those on parent classes. Want to use the
same ActionBean with two sets of validations? Subclass it and specify different validations.
Another change that’s coming in the 1.3 release allows validations to be selectively applied
based on the UI event being serviced. It’s backward-compatible, which means that if you
don’t need this capability, you don’t have to be aware of it. If you need it, it’ll be there.
Struts Action 1
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
Documentation, broad user base, books, and support. If you want a framework that is very
well known and easy to hire for and train on, then Struts is good. Although other projects,
I’d say, are technically superior in different ways, the gap is smaller than folks tend to think.
Really, the web tier is pretty easy and straightforward.
Tapestry
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
I think Tapestry’s real strengths come through on medium- to large-sized projects (although
you can have fun even on a single-page application). Those are the projects where you’ll get
leverage by being able to easily create new components. Tapestry so doesn’t care about
where the data comes from, and a lot of the “project type” is based on that aspect (i.e.,
CRUD vs. RSS feed vs. etc.). I feel Tapestry’s really easy IoC integration (with HiveMind
and/or Spring) is a huge bonus for teams that want to produce strong, testable code.
Trails
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
The sweet spot for Trails is probably applications in which a web interface to a persistent
domain model is needed. Trails is about quickly giving you an interface to your domain
model with no additional code required other than the POJOs themselves. Trails also lets
you customize the appearance and behavior of the interface and includes validation,
internationalization, and security. It does all this without generating any java source code at
all, so people who hate code generators (like me) will be comfortable with Trails.
WebWork
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
For general teams, WebWork usually fits in best with small teams that are willing to get their
hands dirty and learn a lot about the open source tools they use. WebWork is not meant for
the “armchair programmers” who prefer drag-and-drop development. WebWork rewards
users who take the time to learn the framework. For example, those who know the ins and
outs (and read the reference docs, which are quite good) could easily make an ActionMapper
and a Configuration implementation that provide for great use of “convention” in place of
configuration. My most recent example of this makes URLs like
“/project/123/suite/456/test/create” map to
“com.autoriginate.actions.project.suite.test.CreateAction” and automatically pass in the
parameters projectId=123 and suiteId=456. Results are assumed to be “[action].jsp” or
“[action]-[result].jsp”, or can be defined using annotations.
The point is, WebWork is best utilized when used as the basis for a framework within your
application. It works great out of the box too, but that’s not the best sweet spot currently.
Beyond the generalities, WebWork is an absolute must for anyone who is developing a
shipping product that will utilize plug-ins and extensions. Think JIRA, Confluence, or Jive
Forums. Because of WebWork’s broad support for template languages (Velocity and FM),
including complete tag support, writing modules that can be plugged in is much easier. A
single jar can include the actions and view files. The end result is very nice: In Confluence,
you can upload a jar through the admin UI, and the plug-in is deployed dynamically. Again,
this was possible because Atlassian made the commitment to have a solid understanding of
the framework.
Wicket
1. What is your framework’s “sweet spot,” and for what
type of projects should it strongly be considered?
There are 5 sweet spots in my opinion:
1. Wicket is code centric. This attracts people who regard programming as an art rather
than just a vehicle to get things done. With Wicket, you are in control of how
components are created and how they cooperate, and you will be able to directly use
object-oriented programming in your view layer — not just some half-baked variant of
it.
2. Components are truly self contained. They are easy to create (just extend the proper
class) and use (just have them in your class path). They won’t be in the way of other
components, and easy reusability will save your project from copy ‘n paste code. I would
argue that Wicket is #1 when it comes to how easy it is to create custom, reusable
components.
3. Separation of concerns is clear and enforced. You use HTML (or whatever markup you
use) for presentation, components for any dynamic aspects of that presentation, and
models for any business logic.
4. Clean templates. Not everyone is convinced that having this is important, and
sometimes page scripting — like you can do with JSP, PHP, etc. — actually works
faster. But having clean templates certainly makes your templates easier to read and
maintain, and if you have a separate team of HTML/CSS guys, they’ll love it. And
maybe it is just me, but I hate looking at HTML pages with a lot of distracting crap in
them.
5. It scales well for development — just like OO does. Your code’s complexity will grow
linearly at most as your UI becomes more complex. It is easy to increase the number of
people on your team without them getting in each other’s way, and it is a viable option
to hire HTML/CSS wizards to mock up your pages and let your programmers fill in the
dynamic parts. And overall, using Wicket gives you very maintainable code, which will
pay back on larger or longer-running projects.
Wicket is very well suited for intranet/extranet applications, where the UI is relatively
complex and where you want to make the best use of your developer resources. It is a
pleasure to program with, and it will help your junior programmers develop their object-
oriented skills much better than most of Wicket’s competitors.
Tapestry
Nice, and it got much better with version 4. I almost introduced it as the strategic framework
for the company I was working for two years ago, but a colleague (Johan Compagner — also
a Wicket contributor), convinced me to take a look at Wicket. He did two projects with
Tapestry and had a lot of issues with it, and we both liked Wicket’s programmer-centric
approach better than Tapestry’s “pragmatic” approach. Tapestry is easier to scale than
Wicket, and the templates are more flexible in use than are Wicket’s. The price for that is
high, though: things like additional configuration, abstract classes, “rewinding,” and no
completely automatic state handling. A lot in Tapestry brings up the “premature
optimization”’ red flag for me (e.g., page pooling).
Trails
Never used it, so I don’t know much about it.
Spring Web Flow
The framework itself is okay, but Spring Web Flow is exactly the kind of framework stacking
I don’t like. If I wanted to build a workflow-based application, I would use a framework that
is focused on that, like jBMP (which is really great, by the way). Otherwise, I would just pick
a framework that supports the kind of navigation I am looking for.
To be honest, I don’t like all those “flow”-oriented solutions. They impose a documented
oriented and procedural way of programming. Look at the mail client you are using or at any
other app with any UI complexity (including gmail, flickr, amazon)... Are you really thinking
in pages? I like to work like I do with Wicket. Sometimes you go from page 1 to page 2, but
a lot of times, you have a page with tabs and borders and I don’t know what on it, and you
just want to replace that left panel with the search results of the query from another part of
the page and reuse another panel in some other page without having to worry about what
the flow looks like. And I’m glad I don’t have to “flow” my Swing applications, although I
wouldn’t be surprised if people proposed it .
WebWork, Spring MVC, Struts
Model 2 frameworks suck. I used them for years, I am a committer for one (Maverick), but I
totally lost my belief in them (and so did the guy who started Maverick, by the way). I have
seen projects being drained when the complexity of the UI rose. Programmers relied too
much on ad-hoc session usage (try clustering that) and other hacks to work around their
problems. Model 2 frameworks are highly procedural, and programmers don’t learn object-
orientation properly from using them. I would rather hire someone who coded Swing for a
few years than someone who primarily worked with model 2 frameworks because I would
expect the Swing guy to be a better coder in general. Working with model 2 frameworks
means going from hack to hack and back again, and the amount of copy ‘n paste code it
generally results in is something that makes any serious coder sad.
If I had to pick any model 2 framework, I would probably pick Stripes, which at least got
some of the most annoying aspects of model 2 out of the way.