25

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.

6 Answers 6

20

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

4
  • 1
    I'd reference the very complete SpringApplication: dev.vaadin.com/svn/incubator/SpringApplication
    – rochb
    Feb 12, 2010 at 21:13
  • 3
    I was also looking for Vaadin integration with Spring MVC. The answer you gave is integration with Spring (dependency injection etc). I don't see any of that... Thanks Mar 8, 2010 at 14:20
  • I would also add: dev.vaadin.com/ticket/4132 and vaadin.com/forum/-/message_boards/message/112083 but it is basically about the same
    – dma_k
    Oct 13, 2010 at 17:17
  • I agree with Michael Bavin. IoC and Vaadin different is quite different from MVC and Vaadin integration. Vaadin package has an "multiapp" example where multiple Vaadin application runs within one html. I was hoping to see an example where a view in spring MVC is running multiple Vaadin applications.
    – lsiu
    Jan 10, 2011 at 1:51
4

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.

2

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

1
1

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)

1

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.