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. :frowning:

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.