Notification, CDI and Servlets

Hello everyone, this is my first time here, from Accra Ghana. I’m working on a Vaadin 7/ Java EE 7 application and facing a few issues.

First, I’m using CDI (Vaadin CDI plugin) and everything is working great. However, I can’t use an annotated @CDIUI UI instance alone. For what I know, a UI instance annotated @CDIUI without any value defualts to a mapping of /. However, none of my @CDIUI annotated UI classes works without a value argument. This means I’ve no default / mapping.

Secondly, I cannot navigate to an @CDIUI class from a tradtional, servlet mapped class. For instance

public class SetupUI extends UI {
@WebServlet(value = “/*”, asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = SetupUI.class, widgetset = “”)
public static class Servlet extends VaadinServlet {

Works fine alone. But when I do getCurrent. getPage.setLocation(“home”) in the init() method where home is a CDIUI(“home”) annotated class, the page simply reloads /*. The /setup page doesn’t load.

Any ideas and pointers will be appreciated. Thanks

which version of the Vaadin CDI plugin are you using? Prior to alpha3 it used to be that just having a @CDIUI annotation was mapped to the root, but with alpha3 we introduced a new convention for UI and View mappings. If you don’t specify a parameter for the annotation, the class name of the UI or View is used to construct a mapping. The UI or View at the end of the classname is truncated and the camelcase is converted to hyphenated lowercase.

SetupUI is mapped to /setup, TestApplicationUI would be mapped to /test-application.

To map your UI to the root you would add an empty string as the annotation parameter. In your case it would be
public class SetupUI extends UI {

Furthermore, if you’re using a custom servlet with CDI it’s recommended that you extend the VaadinCDIServlet instead of VaadinServlet.

I hope I was of some help, please let me know if your problem wasn’t resolved.

Great! Thanks. It worked. I’m using alpha 3. Now using @CDIUI(“”) maps my UI class to /*. Thanks