Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
CDI UI provider
Hi Guys,
How can I use Vaadin CDI UI (not view!) provider?
I have created my UI privder class:
public class AppUIProvider extends CDIUIProvider {
@Override
public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
if (event.getRequest().getHeader("user-agent").contains("Firefox")) {
return AppUI.class;
} else {
return OtherUI.class;
}
}
}
How can I register/add/use this class?
Never tried but a quick googling suggests an init-param:
https://vaadin.com/wiki/-/wiki/Main/Creating+an+application+with+different+features+for+different+clients
Thanks Nicklas.
I have tried to annotate the my VaadinCDIServlet class with @WebInitParam:
@WebInitParam(description = "Vaadin UI Provider", name = "UIProvider", value = "com.myproject.fw.ui.AppUIProvider")
But it seems, doesn't work. Nothing happend. :(
Hmm. If nothing else helps, you might have to look at the source and how it's used, e.g.
https://github.com/vaadin/cdi/blob/master/vaadin-cdi/src/main/java/com/vaadin/cdi/CDIUIProvider.java
The CDI extension itself appeared to deal mostly with Views
The CDIUIProvider is probably not available as a managed bean so @Specialize:ing it will probably not work
At the moment, CDIUIProvider is hard coded in https://github.com/vaadin/cdi/blob/master/vaadin-cdi/src/main/java/com/vaadin/cdi/server/VaadinCDIServletService.java#L54 . You could create an enhancement request at https://github.com/vaadin/cdi/issues for making it easier to customize.