aspose file tools*
The moose likes Struts and the fly likes MVC Architecture -- Multiple Controllers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "MVC Architecture -- Multiple Controllers" Watch "MVC Architecture -- Multiple Controllers" New topic
Author

MVC Architecture -- Multiple Controllers

Rahul Chavan
Greenhorn

Joined: Dec 02, 2002
Posts: 1
Hi,
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??
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
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.


Matthew Phillips
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.
Regards
Berny Woehrlin
Ted Husted
Author
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
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.


<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>
 
 
subject: MVC Architecture -- Multiple Controllers