Question

I'm thinking about the possibility of using Spring MVC with Vaadin Framework. Are there any documented ways of making them play nicely together ? Also is it a good idea to use them together ? relating to performance; I'm going to run the app on a dedicated server.

To make my question a bit more clear, how can i return a modelandview from a Spring MVC Controller that wll render using Vaadin and can access all the model data.

Was it helpful?

Solution

Spring support for Vaadin is quite new, but there has recently been a lot of talk about it on the forum and some have tested it. Seems to work. There is an article on the Vaadin wiki about it, and some threads on the forum talking about Vaadin + Spring integration:

Wiki: Spring Integration
Forum: can it mill toolkit be integrated with spring application
Forum: Spring integration problem
Forum: Working with Spring
Forum: Spring Integration

OTHER TIPS

Not sure if it is a prudent choice to integrate vaadin with Spring MVC. Its a waste. MVC is meant for typical page based web apps where as vaadin is more view state based like a desktop app. I would typically do a meet in the middle and have my business tier and data access layer in spring and use Vaadin as is.

See this thread on the Vaadin forum for my AutowiringApplicationServlet solution, including a sample WAR application.

agreed with dhrbo.

its not wise to use spring mvc, more so with webflow with vaadin. vaadin is another web-app framework.

if you want the idea of "spring mvc" in your vaadin project, integrate it with spring-core, beans and context. that way you can get a clear separation between controllers, ui (vaadin), and models (integrate with hibernate / orms)

Here's an article on integrating Spring service layer with Vaadin. It does not directly relate to Spring MVC that the original question was about, but it can still be a pointer for other readers researching Vaadin Spring integration.

http://psponcoding.blogspot.com/2011/03/vaadin-spring-integration.html

org.springframework.web.servlet.mvc.Controller's handleRequest takes a HttpServletRequest and HttpServletResponse as parameters. From these, you cannot process the URI fragment. As such, the controller is not suited for controlling requests based on URI fragment.

In my application, I implemented very similar concept to Spring controller. My application still has a notion of "views" and "model". Each view is implemented in a separate class and is displayed in a central block of the page. I wanted to centralize logic of the URL processing to that class, so I created a class AbstractControllerEntry:

public static abstract class AbstractControllerEntry {
    public abstract boolean matches(String fragment);
    public abstract void open(MainWindow window, String fragment);
}

with several convenience subclasses such as ConstantEntry, PrefixEntry and RegexEntry.

Each view class has a static method, that returns AbstractControllerEntry. Collection of all entries is kept in a static array inside of MyController class (not a Spring MVC controller). Upon fragment change (see UriFragmentUtility), I iterate all entries, and for first, which matches, I will call open. Any other logic, such as finding the model object, is inside of the view class, in the AbstractControllerEntry implmentation.

Additionaly, there's another static method to generate the URI fragment in the view class, so that each reference to a view is a real reference to a class, this is a solution to broken links. And each view has instance method to get a fragment for current view, which is checked to match a controller entry to increase robustness.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top