Chapter 6. Leveraging Actions
Introduction
Actions control the flow of data and navigation in a Struts
application. Each
Action acts like a decision point in a flow chart.
It's the place where you can decide what data to
create, what data to save, and where to send users based on their
input. A Struts application doesn't require that
every request be routed through an Action, but
doing so gives you a level of control that will allow your
application to adapt as requirements and new features are changed and
added.
Do you feel like your application is exploding with hundreds of
custom Actions? If it is, you
aren't alone. This condition can be acceptable, but
you may not be leveraging Struts Actions to their
full extent. Using the recipes in this chapter will enable you to get
more reuse from your Actions and reduce the number
of custom classes that you have to maintain.
A number of the recipes in this chapter utilize
Action subclasses included with Struts. These
pre-built actions are found in the
org.apache.struts.actions package. Some of these
actions are designed to be extended, and others are used as is. The
DispatchAction and its provided subclasses,
LookupDispatchAction and
MappingDispatchAction, fall into this first
category. These actions reduce the amount of code you have to write
by replacing multiple related Actions with a
single Action that supports multiple operations.
You use two other pre-built actions, ForwardAction
and IncludeAction, directly—no subclassing required. These ...