File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Override DispatchAction but keep the existing funcationallity

 
ashish kulkarni
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
cc.doValid();
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
Ashish
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic