In a Model - View - Controller architecture, in general, and a Struts framework, in particular, Control objects provide several main functions: determining the user's intended action, preparing data in a form suitable for transfer to the Model, calling the appropriate method in the Model, preparing return data for display in a View, and branching to the appropriate View. All of this function is sometimes referred to simply as Navigation.
The UI Control layer resides between the UI View layer and the UI Model layer, if one exists, or, otherwise, the EJBSession layer.
The strategy for generalization is a bit more complex to understand than for classes that use conventional Java classes or for SessionEJBs, but implementing subclasses is not difficult. The basic approach is this. the Struts Action class extends only Object and includes an execute method that is called by the (invisible) ActionController within the framework. It is here that the main logic of the class is defined. Thus, one normally extends Action and overrides the execute method, similar to the strategy used for Servlets that override doGet and/or doPost methods.
Recall that Struts provides several important bindings thorugh the XML-based structs configuration file. These bindings include the ActionMapping and ActionForward objects that define navigation as well as the ActionForm object that transfers data to and from View objects. Actual objects for these parameters are only available to an actual subclass that represents a specific action. For these paameters to be used in a superclass, where one would like to perform a substantial amount of generic functions, they must be passed from the subclass to the superclass.
Thus, the basic strategy is to override the Action class's execute method in the subclass. When it is called, it calls the superclass's execute method, passing it the parameters it has received. It then returns the ActionForward object that is eventually returned to it by the superclass.
Meanwhile, the superclass, having received from the subclass its ActionForm object, can extract user data, determine the desired function, call the appropriate method on the appropriate model, and return the appropriate ActionForward object. Generalization is obtained through two methods that the suprclass's execute method calls: one for generic functions -- CRUDS plus several others -- that it implements with the help of several abstract methods and a second method for subclass extensions, which is abstract and implemented by the subclass.
Struts Action Interfaces
Interfaces do not play a role in generalization for this layer. Rather, methods are overridden and abstract and support methods defined.
Struts Action OOC
ActionOOC is the superclass for all OOC subclasses. It extends the Struts Action class, as do all Struts action objects. It includes a set of global variables available to it as well as its subclasses, a logical framework that calls two methods that provide all processing of user actions, including both generic and subclass-specific actions, and a set of abstract support methods.
Struts Action Set
ActioinSet is a subclass that extends ActionOOC and overrides its execute method. It also implements the superclass's abstract methods, including a method to provide the additional function that extends the basic set of methods (e.g., CRUDS) supported in the superclass.