File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LookupDispatchAction vs. traditional Action

 
Vicky Pandya
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is advisable and best practice in following situation.

On average, on single HTML form there are 4 buttons. Is it a good practice to extend LookupDispatchAction and have one action class per JSP? Or just extend traditional action class per button click? This way it will have 4 different action classes for single HTML form. However in terms on maintenance and debugging later will be easier?

What's the best practice to extend LookupDispatchAction or simple Action? Merits- Demerits?
 
vidya sagar
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go for LookupDispatch Action it is only easy for maintenance, if any changes change in one place is enough.
 
Vicky Pandya
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maintenance can be looked from two perspectives

1)If DO NOT USE LookupDispatchAction then less code in one action class, which is easy to maintain in compare to having 4 methods in single action class. However this will increase number of files but should be easy to maintain.

2)IF DO USE LookupDispatchAction:- Less number of action classes with more than 1 methods in single class file.

What's the prefer way and best practice? Does anyone know merits and demerits of these two alternatives?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no "best practice" in this area. It's a matter of preference and programming style.

One thing that hasn't been mentioned, though, is this: Many of us like to code an abstract base action class for an application that performs tasks common to all actions (checking for login, logging, etc.), and then have all of our Action classes extend this base class. If you use DispatchAction or LookupDispactchAction, it's much more difficult to make these actions extend a base class.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic