wood burning stoves 2.0*
The moose likes Struts and the fly likes Override DispatchAction but keep the existing funcationallity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Override DispatchAction but keep the existing funcationallity" Watch "Override DispatchAction but keep the existing funcationallity" New topic

Override DispatchAction but keep the existing funcationallity

ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 130
I want to extend functions of dispatchAction class, like i want a class which extends DispatchAction and overrides the execute method, But keep all the existing functions,
But if i override the execute method, then i will have to code the same function available in origianl DispatchAction, and add my extra functions, ( like cut and paste the code) but then if in future DispatchAction is modified i will need to modify my class.
or have one class which will have all the functions of DispatchAction , but also want to add more functions.
What i have done in MyActionClass is
public abstract class MyAction extends Action
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request,
HttpServletResponse response)
throws Exception
//common code for all action classes
CommonClass cc = new CommonClass();
// just sample method
return performTask(mapping, form, request, response);
// this is the method which will be implemented by each overriding class and add the necessary logic
protected abstract ActionForward performTask(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws Exception;
I have a CommonClass for doing all the common function,
How can i do it DispatchAction

I agree. Here's the link: http://aspose.com/file-tools
subject: Override DispatchAction but keep the existing funcationallity
Similar Threads
How to Check Session in Controller
How to link different buttons to different action methods
Dispatch Action Issue/Exception
Please review code for LookupDisptach using Image Buttons
Error: DispatchMapping[/login] does not define a handler property