Elbek
Elbek

Reputation: 3484

Spring render many many view for one page

Hello I am using spring mvc and my page consist of 2 columns left and right. I want that left side is rendered from one controller and right side is rendered another one. How to accomplish that. Fore example in the right side here is login form which renders from LoginController but the left side changes all time. How to accomplish it with spring mvc framework.

thanks in advance.

Upvotes: 0

Views: 316

Answers (2)

pap
pap

Reputation: 27614

Spring MVC is not inherently a component-oriented framework, like you seem to want. Some different approaches that might suit you

  • Client-side aggregation. Load your different "components" (left, right) using AJAX
  • Using some more template/component-oriented rendering framework. I like Apache Tiles and breaking out logic in Preparers (analogous to Controllers in Tiles). Or you can use JSF 2. I wrote a bootstrap/tutorial on Spring MVC 3 and JSF 2 a while back that might be interesting for you.
  • Go full-on with a component-oriented framework like JSF 2, Tapestry or Wicket.

Upvotes: 2

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340873

There are various ways to implement this. What are your exact requirements? You can try:

  1. Portlets - render two portlets, each is rendered separately. Probably an overkill if this is needed only in this one place.

  2. AJAX - Render an empty page first and fetch both views separately using AJAX. See $.load().

  3. <iframe/> - embed iframes with two different target URLs.

  4. Use component-oriented framework (I personally like Wicket).

None of these approaches are tied Spring MVC or even Java.

Upvotes: 1

Related Questions