| Author |
Best practice controller implementation for different actions
|
Harshana Dias
Ranch Hand
Joined: Jun 11, 2007
Posts: 325
|
|
Suppose I have actions like edit delete and update. If so what is the best practice to implement the controllers. Is it like one servlet map to different actions or separate servlets for each action?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
|
One servlet is much more common. That's how most web frameworks work as well. One servlet to delegate to the proper class that does the work. You want to avoid having non controller login in that servlet though. Your logic should be in other classes you delegate to. And there would be one of those per action.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Harshana Dias
Ranch Hand
Joined: Jun 11, 2007
Posts: 325
|
|
Jeanne Boyarsky wrote: Your logic should be in other classes you delegate to. And there would be one of those per action.
Those are the model classed in MVC architecture know.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
Harshana Dias wrote:
Jeanne Boyarsky wrote: Your logic should be in other classes you delegate to. And there would be one of those per action.
Those are the model classed in MVC architecture know.
No, that's not what's she's talking about. Perhaps this article can help.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Piyush Mangal
Ranch Hand
Joined: Jan 22, 2007
Posts: 196
|
|
|
It is fine to have one controller for both delete and update action as long as they can be functionally grouped. Even frameworks like Struts and Spring MVC had DispatchAction and MultiActionController for the same usecase.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
Piyush Mangal wrote:It is fine to have one controller for both delete and update action as long as they can be functionally grouped. Even frameworks like Struts and Spring MVC had DispatchAction and MultiActionController for the same usecase.
That's true. The original poster didn't sound that far down in design so I answered differently.
|
 |
 |
|
|
subject: Best practice controller implementation for different actions
|
|
|