views:

293

answers:

1

I am designing a web application that requires loading multiple components on a single page. (In terms of page layout is similar to Google reader) I like to keep these components separate from each other (for reasons such as reusability). For example, I have a left panel that let's user navigate among multiple feeds that he's subscribed to (user specific) and on the right side of that we show the contents of that feed, and maybe a right panel which shows some specific info about that specific feed. My understanding of MVC and more specifically Spring-MVC is that each controller is in change of the entire page. Here are 2 solutions that I have came up with after researching this a bit, and none of them sounds good to me. 1 - Have a main controller that is mapped to that URL, and then load the other components from inside the jsp file. This is doable but doesn't sound like a good solution 2- using portlets.

I want to know what are the best practices. This sounds like a very common web design issue in MVC frameworks, how do people do it?

+1  A: 

Spring MVC controller is usually "in charge" :-) of handling a particular request which does not necessarily mean that said request results in a monolithic page being presented to user.

Since you're talking about Google Reader-like functionality, perhaps you'll be using AJAX to load / navigate between different components on your page? If that's the case, you can easily map your 3 components to separate controllers (via separate URIs) plus have one "main" controller to initially load the entire page.

If that's not the case and your page is static, you can have your controller act as "router" of sorts by first instantiating your components and then directing commands / requests to an appropriate component as necessary. Each component would update its own part of the model after which your "main" controller would return the view to be rendered.

Can you use portlets for this? Sure. But if we're talking about a single page it might be a tad overkill.

ChssPly76
Thanks for the answer! It certainly can be done the way you described.After reading and testing couple of other frameworks, I finally decided to use a component oriented framework. Right now, I think that would be Wicket.
shane