We are currently using DispatchActions extensively. At times we would like to chain functions within different DispatchActions together. The trick is to modify the parameter you are using such as "method" or "dispatch" before you send it to the next DispatchAction. Currenly we modify the parameter in struts config file by tacking it onto the end of the path value. For example the path in the forward mapping would be
Is there a better way to do this? Should I not be using DispatchActions? You input is appreciated!
Without knowing what your DispatchActions do, I would guess that you would be better off creating utility/helper classes to handle the work. That way your core functionality is not piecemealed across the Actions.
Having DispatchActions is not a bad thing but if you find yourself wanting to chain them so they can borrow from each other, you would be better off creating an outside method that multiple actions can use.
I find using DispatchAction a bit restrictive at times, but this is just my opinion. It requires that you do a really detailed analysis and design of your application. However, even if the application is well designed, it needs to be flexible enough to cater to changing requirements. DispatchAction, I feel, does not provide this flexibility.
Advantages of DispatchAction: - combine many similar actions into a single Action class, in order to simplify application design
Disadvantages of DispatchAction: - difficulty in action to action forwarding - mapping characteristics of this Action must be shared by the various handlers (action methods). This means that all actions have to share the same form bean and validation. - a request parameter is visible to the end user
Using the MappingDispatchAction removes the disadvantages associated with DispatchAction. However, you do end up with an increase in the number of action mappings in the struts-config.xml file. But this is not really an issue since each handler (action method) can now be configured individually.