Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Migrating to Struts 2, Part 2; First Struts 2 Dev Build Released

Migrating to Struts 2, Part 2; First Struts 2 Dev Build Released

Part 2 of Migrating to Struts 2 has been published on InfoQ, and on Oct 10th, the first public release of Struts 2, the first development build (2.0.1) was made available. Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts 2. This new version of Struts is designed to be simpler to use and closer to how Struts was always meant to be.

In the first part of the article series, Ian explained (for Struts developers) the high level architecture, basic request workflow, configuration semantics and differences in the action framework in the new Struts 2 (formerly WebWork) and Struts 1.  In this part of the Struts 2 migration series, Struts committer Ian Roughely looks at a real application and compares the Struts and Struts 2 implementations, identifies how to convert actions, configuration changes, and what parts of the codebase don't need to be converted.

Read Migrating to Struts 2, Part II, published today.

According to the Struts 2.0.1 release announcement, some key changes are:
  • Smarter!
    • Improved Design - All Struts 2 classes are based on interfaces. Core interfaces are HTTP independent.
    • Intelligent Defaults - Most configuration elements have a default value that we can set and forget.
    • Enhanced Results - Unlike ActionForwards, Struts 2 Results can actually help prepare the response.
    • Enhanced Tags - Struts 2 tags don't just output data, but provide stylesheet-driven markup, so that we can create consistent pages with less code.
    • First-class AJAX support - The AJAX theme gives interactive applications a significant boost.
    • Stateful Checkboxes - Struts 2 checkboxes do not require special handling for false values.
    • QuickStart - Many changes can be made on the fly without restarting a web container.
  • Easier!
    • Easy-to-test Actions - Struts 2 Actions are HTTP independent and can be tested without resorting to mock objects.
    • Easy-to-customize controller - Struts 1 lets us customize the request processor per module, Struts 2 lets us customize the request handling per action, if desired.
    • Easy-to-tweak tags - Struts 2 tag markup can be altered by changing an underlying stylesheet. Individual tag markup can be changed by editing a FreeMarker template. No need to grok the taglib API! Both JSP and FreeMarker tags are fully supported.
    • Easy cancel handling - The Struts 2 Cancel button can go directly to a different action.
    • Easy Spring integration - Struts 2 Actions are Spring-aware. Just add Spring beans!
    • Easy plugins - Struts 2 extensions can be added by dropping in a JAR. No manual configuration required!
  • POJO-ier!
    • POJO forms - No more ActionForms! We can use any JavaBean we like or put properties directly on our Action classes. No need to use all String properties!
    • POJO Actions - Any class can be used as an Action class. We don't even have to implement an interface!

Rate this Article