Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Art of Java Web development: WebWork

Build Model 2 applications with WebWork

WebWork is an open source Web development framework for building Model 2 applications. Philosophically, it is closer to Struts than Tapestry. It works within the existing Web APIs in Java rather than attempting to replace them completely. WebWork contains several concepts and constructs that are unique and that set it apart from other frameworks, such as the Pull Hierarchical Model-View-Controller design and the value stack, which supplies values to their custom JSP (Java Server Pages) tags. We begin with a history and background of the framework. We then explore some key concepts and constructs that are vital when you're working with the framework. As always, the principles of Model 2 development provide the guidelines for the samples and dictate a firm separation of concerns.

Overview

WebWork is produced by the Open Symphony project. This project includes many embedded projects; WebWork is just one of them. The framework is currently at version 1.3, and you can download it from the Open Symphony Website. It is based on best practices and design patterns that have long-standing records of accomplishment-patterns such as Model-View-Controller, the J2EE Front Controller, and others. It is also based on a strong motivation to keep things as simple as possible while maintaining flexibility (which the creators acknowledge is a difficult balancing act).

WebWork implements what its documentation calls "Pull Hierarchical Model-View-Controller," or "Pull HMVC." This is the creators' own take on the Model 2 design. The "pull" part of this definition indicates that the view component is responsible for pulling the model information from the controller on demand. This is different from the traditional Model 2, where the view accesses information that has been placed within the model and passed to it from the controller. In this case, the view understands what information it wants and accesses it without necessarily having to wait for a controller to make it available. This architecture requires the presence of a repository of data available to all views, which access it on a just-in-time (JIT) basis.

The "hierarchical" part of the description describes the repository of view data. In the case of WebWork, the "value stack" is used to provide information to the view. (We describe this construct in the "Expression Language" section below.) The rest of the architecture is Model-View-Controller. That means that WebWork enforces the normal semantics of Model 2, but with a different twist on how that model information is made available. WebWork is not the only project to use this approach. Turbine's documentation and white papers also refer to this "pull" paradigm of Model 2.

WebWork takes advantage of the Web APIs in Java rather than hiding them. However, it doesn't rely on them as much as unadorned Model 2 or Struts. Like Struts, WebWork includes a central controller, based on the J2EE Front Controller design pattern, which creates Action objects (thus using the Command design pattern). However, the return and packaging of model information is different in WebWork.

The architecture

The architecture of WebWork follows the common architecture of most Model 2 Web application frameworks. The figure below shows the overall architecture and flow.

The WebWork architecture has much in common with unadorned Model 2 and Struts, with changes

You can configure WebWork through configuration files. When WebWork starts, the ServletDispatcher is invoked. This is the main controller for WebWork, similar to other Model 2 frameworks. The ServletDispatcher reads several configuration files (covered in "The Configuration" section below) and uses that information to create an Action object to handle the request. The action in turn creates model beans, which access data, mutate it, and otherwise perform the real work of the application. WebWork does not require the use of model beans. Properties can appear directly in the Action class but shouldn't for most Model 2 applications because such an arrangement violates the separation of responsibilities.

The action returns a response code, used by the ServletDispatcher to look up the appropriate view. The ServletDispatcher dispatches control to the view component, which can be any view framework (for example, JSP or Velocity), or it can be an action chain, which will execute another action. The view extracts information needed from the value stack. The framework maintains this construct by caching information from both actions and model beans for use by the view. The value stack is discussed in "The Expression Language" section.

On the surface, WebWork looks just like the architectural diagram for Struts. However, the details of information flow are different. WebWork makes accessing information kept in actions and model objects easier by handling much of the information transport for you. WebWork includes numerous custom JSP tags that are savvy about the information flow within the framework.

1 | 2 | 3 | 4 | 5 | 6 | 7 |  Next >

Discuss

Start a new discussion or jump into one of the threads below:

Subject Replies Last post
. Art of Java Web development: WebWork
By JavaWorldAdministrator
1 04/05/08 06:05 PM
by Anonymous


Resources