Posted By:
Ted_Husted
Posted On:
Tuesday, October 30, 2001 04:38 AM
An Action is intended as an adapter between the HTTP layer
and the rest of your application. Generally, the rest of your
application should be represented by business objects
that have no dependancies on HTTP or Struts.
So, the business logic should not be *in* the Action,
but something that the Action *calls*.
This makes it easier for Actions to handle more than
one task. Since the logic is encapsulated elsewhere,
each task is simpy a method call.
This also makes it easier for logic to be accessed by
more than one Action (or from more than one application).
In this case, there could be a business method for the
listResult page, that an Action could call before forwarding
to that page.
If the correct prerequesites are still in the request,
simply forwarding to another Action can also be a clean
solution, so long as this is documented in the struts-config.
Where it gets iffy is when people start building
dynamic query strings so they can call another Action.
This is a retreat to Model 1, and smells like a kludge, since
it implies that the business logic is not available outside the
Action, where it could be cleanly called with a method (rather
than a query string).
For an example of using business objects with Struts,
see the early release of Artimus at
http://husted.com/struts/resources.htm#new.
HTH -Ted