Forums Register Login
MVC Architecture -- Multiple Controllers
I have an application where the login is controlled by the Main Controller(Which in turn calls helper objects to authenticate) and then serves the main page.
When the user clicks on an option presented in the main page, the application then calls another controller which is the main controller for that module.
I talked to a senior architect and he says that this sort of design is wrong.
Any thoughts??
It sounds to me like it breaks the MVC pattern, but I am not an expert on the matter. Are you asking specifically about Struts? If so, the controller is built to support multiple modules through parameters in the web.xml file.
Hi Rahul,
I prefer to have on MainAction class which handles all the standard things any Action should contain in a similar way: Session management, user authentication (by calling a Helper class...), etc. Then I subclass this MainAction and add the module-specific controller logic...
Hope this is some help.
Berny Woehrlin
Some applications do use multiple "controllers", but most architects now seem to prefer using a single "front controller" to receive all the initial requests. The front controller can then delegate the actual processing to a "dispatcher".
Multiple controllers often add complexity without any additioinal benefit. Since servlets are multithreaded, there is no performance advantage of using multiple controllers when one would do as well.
The Struts framework uses a single front controller (the ActionServlet) and multiple dispatchers (the Actions). This generally works quite well, but I often think allowing mutliple front controllers would make team development easier. In Struts 1.1, we are experimenting with application modules, but it seems like we are starting to replicate features already found in the container.
So, there is no technical advantage to having multiple controllers. But it might simplify configuratiion issues when each team (or "module") can use its own controller.
HTH, Ted.
look! it's a bird! it's a plane! It's .... a teeny tiny ad
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter

This thread has been viewed 1733 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 20, 2018 18:45:33.