On Thu, 18 Mar 2004 15:24:25 +0300, AKostylev wrote:
> How can I avoid action chaining in such situation... In my
> application user can set "resolution" on some "demand". For
> example, there two types of resolutions: "bug" and "not a bug". If
> user selects "not a bug" option on form, then nothing happens...
> But if user selects "bug" option, then he must create object "bug".
> But also user can create object "bug" from another place of
> application. So I get two actions: ResolutionSelectAction and
> BugCreateAction, how can avoid action chaining between them and
> move this dependence to business logic?

The Actions should not be implementing the business logic. The business logic should 
be behind a facade where any Action can call it. In this way, if multiple Actions need 
to call an operation, like "createBug", they can. The facade can simply be a JavaBean 
placed in application scope by a Plug-In, as is done with the Struts MailReader 
example. If the facade is based on an interface, as is done with MailReader, you can 
change the implementation of the facade whenever you like.

The Action's job is not to create business objects, but to *decide* whether an object 
needs to be created. When any Action anywhere needs to create a business object, they 
should be able to call a method on the facade. Actions should represent the workflows 
or "scripts" (to  use Fowler's term) within an application, not the underlying 
business operations. The idea is that the user makes a request, and the Action 
fulfills that request, calling whatever business operations it may need along the way.

Another responsibility of the Action is to select the resource that will complete the 
response, usually by rendering a page. Sometimes this resource may be behind another 
Action. But this is not an instance of Action Chaining, since a "resource" Action (or 
PageLoader) seeks to complete the response, rather than fulfill the request.

Another way to think of the facade is as a set of services, like Web Services. Any 
time anyone needs to work with a business object, they should be able to call a 
service to handle the implementations details. All the Actions see are signatures.

-Ted.

----
Developing Web Applications Using Open Source Tools
Saturday, 3 Apr 2004, New York City
http://basebeans.com/do/website



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to