Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Art of Java Web development: WebWork

Build Model 2 applications with WebWork

  • Print
  • Feedback

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.

  • Print
  • Feedback

Resources