ActionForm

These are Java classes that extend the Struts org.apache.struts.action.ActionForm class, commonly referred to as form beans. They are server side Java objects used to represent the state of an HTML form and may be stored in the request or the session.

The following points give a brief description of how form beans are handled in generic Struts applications using the default RequestProcessor:

A request is made on the ActionServlet.
The RequestProcessor locates the Action configured to handle the request.
The RequestProcessor locates (or creates if necessary) the associated form bean and calls the reset() method. NOTE: Form beans stored in the request scope are created on each request, whereas session forms persist between sessions.
The RequestProcessor populates the form bean using the request parameters.
The form bean validate() is called and if there are any errors then control is forwarded to the "input" forward defined in the action mapping. If there were no errors then the Action is given the chance to process the request. This may involve accessing variables on the form bean, and possibly setting new data on it.
The Action may return an ActionForward that is a JSP. The JSP also has the opportunity to access and modify the form bean as it desires.

ValidatorForm

The application architecture utilises the Validator module which provides an extension to the default ActionForm called ValidatorForm. It processes the form bean using the Validator when the validate() method is called. All form beans used by the application subclass ValidatorForm to utilise this functionality.

Form and Transfer Objects

Form beans store information in Form and Transfer Objects where possible. The hierarchy that this creates on the form beans is well suited to the Struts Nested Taglib in JSPs.

Form scope

All form beans are session scoped, meaning they are stored in the users session. Although request forms are sometimes preferable, it was decided that the reduced complexity of using session forms outweighed the negative aspects (such as memory use).

Related topics

ActionServlet
Action
Validator
Form Object
Transfer Object
Struts taglibs