Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
More action with Struts 2
In a recent review of Struts 2 in Action, JW Blogger Oleg Mikheev notes that Struts 2 is "just a collection of extensions built upon WebWork, which is ultimately
the right thing to learn before starting a Struts 2 project." While Struts 2 has some architectural flaws, Oleg calls WebWork
well-designed, well-tested, and reliable. What are your experiences using Struts 2 and WebWork?
Also see "Hello World the WebWork way," a JavaWorld excerpt from WebWork in Action, by Patrick Lightbody and Jason Carreira.
| Memory Analysis in Eclipse |
| Enterprise AJAX - Transcend the Hype |
Here are four possible steps (and substeps) involved in form processing implementation:
As you can imagine, or have experienced, implementing all these steps is quite a job. In this article, I'll show you how the Form Processing API can help you simplify this process.
Let's start with an object-oriented analysis of the form processing domain, at the class level. With a bit of OO brainstorming,
I came up with the two main classes, FormElement and Form, and one interface, FieldController.
The FormElement class represents the general concept of all form input elements: text fields, password fields, text areas, checkboxes, radio
buttons, combo boxes, and list boxes. In spite of what it specifically represents, a FormElement object (also referred to herein as "field") has four main states (variables):
name identifies the field (FormElement) to the server
value represents a value that the field carries to the server
required represents a flag that shows whether or not an entry for the field is required
errorMessage represents a message that will display a warning, an error message, or nothing beside the field's graphical representation
The first three variables require no further explanation, but the fourth one brings up the question, what would that text
message be? With radio buttons, checkboxes, combo boxes, and list boxes, the errorMessage can:
With text input fields like text fields, text areas, and password fields, the errorMessage can:
As you can see, the last two types of warning messages cannot be categorized (or hard-coded in the API), because their variation
is infinite. In every infinite situation, FormElement needs some help to generate an errorMessage. Here is where interfaces come into play.
Since errorMessages for text input fields vary infinitely, the action for generating them varies infinitely too. But the scenario is always
the same: a value is given, and a derived errorMessage is required. It all sounds like a method that takes value as an argument and returns errorMessage, while the implementation of that method is unknown.
FieldController is an interface that only defines one method, getErrorMessage(). This method takes a string value (being validated) as an argument and returns a string errorMessage.
A FormElement object, which represents a text input field, uses an object of type FieldController to implement validation criteria for its value. In this case, the FieldController object is said to be registered with the FormElement. For that purpose, the FormElement class has a method called addFieldController() that takes a FieldController object as an argument. Nothing can go wrong when a FormElement registers more than one FieldController.
The Form class represents the concept of a whole set of FormElements. A Form object is responsible for processing a number of FormElement objects that belong to the form. Its process() method validates all field values, and returns "true" when all values are accepted, or "false" otherwise. See Resources for a look at the Form Processing API docs, and more information on Form and other classes.
To stay on track, I won't go deeper into this analysis. The simple UML class diagram below shows all the classes the API includes (in terms of methods, it only contains the most commonly used ones).

Figure 1. UML class diagram of the Form Processing API
All these classes belong to the iostrovica.form package. Check Resources for this package's class files, and the API specification.
In the J2EE programming model, JSP pages, supported by servlets, are responsible for delivering dynamic Web content to the client, and the complex business logic tasks should be encapsulated within JavaBeans components (or custom tags). The Form Processing API can be seen as an extension of the Servlet API. Its classes follow the JavaBean standard, giving you the comfort of enjoying all JSP and JavaBean features.