Want to change the main screen depending on role

Hi i want to check if the user has a specific role I want to change the loaded screen.
this works if I have the open mode to dialog but if I change it to root I get please contact administrator and no error in the catalina out. How can I achieve this? Thank you!!

@Subscribe
public void onMainScreenInit(InitEvent event) {
logoImage.setSource(RelativePathResource.class)
.setPath(“VAADIN/brand-login-screen/logo-pvs-Main.png”);

    if (userService.isEmpresa()) {
        Empresa empresa = empresaService.getByCurUser();
        if (!empresa.getCalificada()) {
            // WANT TO CHANGE THE SCREEN IN THE WORK AREA TO THIS DEPENDING ON THE USER ROLE
            screenBuilders.editor(Empresa.class, this).withOpenMode(OpenMode.ROOT).editEntity(empresa).build().show();
        }
    }
}

I need all this to happen as soon as I LOGIN

Why are you using OpenMode.ROOT? It’s only for the main and login windows. Use THIS_TAB or NEW_TAB, and the screen will open in the work area of the main window:

@UiController("extMainScreen")
@UiDescriptor("ext-main-screen.xml")
public class ExtMainScreen extends MainScreen {
    @Inject
    private ScreenBuilders screenBuilders;

    @Subscribe
    public void onAfterShow(AfterShowEvent event) {
        screenBuilders.screen(this)
                .withScreenClass(FooScreen.class)
                .withOpenMode(OpenMode.THIS_TAB)
                .build()
                .show();
    }
}

Regards,
Konstantin

I had tried…with the other open modes… and I get a generic error that prints nothing on catalina out…

I had my code on
public void onMainScreenInit(InitEvent event)

changing the event to onAfterShow worked as expected

Thank you!! Thank you !! Thank you !! so much for bailing me out all the time !!!