I am tring to add vaadin to my Spring MVC project. Basically I need to take advantage of both jsp view and vaadin generated viewes.
I need to use jsp for frontend let’s say http://localhost:8080/HelloWorld/ and use vaadin for admin section http://localhost:8080/HelloWorld/admin.
URL: http://localhost:8080/HelloWorld/hello
The Spring Controller is working when I hit this
URL: http://localhost:8080/HelloWorld/admin
BUT vaadin controller give me following error with this
javax.servlet.ServletException: com.vaadin.server.ServiceException: com.vaadin.server.ServiceException: No UIProvider has been added and there is no “UI” init parameter.
/////////////////// web.xml //////////////////////
Web Application
dispatcher
org.springframework.web.servlet.DispatcherServlet
1
dispatcher
/
dispatcher-vad
com.vaadin.server.VaadinServlet
1
dispatcher-vad
/admin/*
/////////////////// dispatcher-servlet.xml //////////////////////
<context:component-scan base-package=“com.programcreek.helloworld.controller” />
/WEB-INF/views/
.jsp
/////////////////// HelloWorldController.java //////////////////////
@Controller
public class HelloWorldController {
String message = “Welcome to Spring MVC!”;
@RequestMapping(“/hello”)
public ModelAndView showMessage(
@RequestParam(value = “name”, required = false, defaultValue = “World”) String name) {
System.out.println(“in controller”);
ModelAndView mv = new ModelAndView("helloworld");
mv.addObject("message", message);
mv.addObject("name", name);
return mv;
}
}
/////////////////// dispatcher-vad-servlet.xml //////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<bean class="com.programcreek.helloworld.vad.controller.MyVaadinUI.MyConfiguration" />
<context:component-scan base-package="com.programcreek.helloworld.vad.controller" />
/////////////////// MyVaadinUI.xml //////////////////////
@Theme(“valo”)
@SpringUI(path = “”)
@SuppressWarnings(“serial”)
public class MyVaadinUI extends UI {
@WebServlet(urlPatterns = {"/admin/*", "/VAADIN/*"}, asyncSupported = true)
public static class Servlet extends SpringVaadinServlet {
}
// @WebListener
// public static class MyContextLoaderListener extends ContextLoaderListener {
// }
//
// @Configuration
// @EnableVaadin
// public static class MyConfiguration {
// }
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
Button button = new Button("Click Me");
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label("Thank you for clicking"));
}
});
layout.addComponent(button);
}
}