vaadin / quarkus

An extension to Quarkus to support Vaadin Flow
Apache License 2.0
28 stars 3 forks source link

CDI not working in parent layouts #75

Closed dasfuu closed 1 year ago

dasfuu commented 2 years ago

Vaadin Version: 23.1.0.beta1 Quarkus Version: 2.8.2.Final

I have a view and a parent layout. I cannot @Inject in the layout class with Quarkus. But I can in a project deployed in a Wildfly Server.

@Route(value = "", layout = MyLayout.class)
public class MainView extends VerticalLayout implements AfterNavigationObserver  {

    @Inject
    Something someService; //this works

    @Override
    public void afterNavigation(AfterNavigationEvent afterNavigationEvent) {
        System.out.println(someService); //Prints null
    }

}

@Route(value = "", layout = MyLayout.class)
public class MyLayout extends AppLayout implements AfterNavigationObserver {

    @Inject
    Something someService; //this does not work

    @Override
    public void afterNavigation(AfterNavigationEvent afterNavigationEvent) {
        System.out.println(someService); //Prints class instance
    }

}
mcollovati commented 1 year ago

Seems like RouterLayout implementors are not considered during bean discovery. We should manage them in the same way we do for HasErrorParameter implementors