Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppShellSettings.getUi returns null #12678

Closed
Artur- opened this issue Jan 5, 2022 · 4 comments
Closed

AppShellSettings.getUi returns null #12678

Artur- opened this issue Jan 5, 2022 · 4 comments
Labels
hilla Issues related to Hilla

Comments

@Artur-
Copy link
Member

Artur- commented Jan 5, 2022

Description of the bug

When I implement AppShellConfigurator and override the configurePage method I expect to be able to use the provided getUi() method on AppShellSettings to get the target UI instance, like the javadoc says. However, calling getUi() returns an Optional which has a null value.

Expected behavior

getUi should return the UI instance so I for instance can configure push parameters.

Minimal reproducible example

@SpringBootApplication
public class Application extends SpringBootServletInitializer implements AppShellConfigurator {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void configurePage(AppShellSettings settings) {
        System.out.println("UI is " + settings.getUi().get());
    }
}

Versions

Vaadin: 22.0.2
Flow: 9.0.2
Java: Homebrew 11.0.12
OS: aarch64 Mac OS X 12.0.1
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

@caalador
Copy link
Contributor

caalador commented Jan 7, 2022

Without deeper knowledge on the AppShellSettings feature I noted that there is in use the error message:

    private static final String MSG_UNSUPPORTED_NO_UI = "It only works when "
            + "useDeprecatedV14Bootstrapping is enabled. "
            + "Use a UIInitListener instead if there are server-side views.";

for many methods which would sound like getUI will not return a UI in a early state if not using the v14 bootstrapping.

Fusion/Hilla team should perhaps have a look at this though.

@caalador caalador added the hilla Issues related to Hilla label Jan 7, 2022
@platosha
Copy link
Contributor

True, this is by design, getUi cannot return UI there in the default mode, because it has not been created yet. In fact it was wrapped in Optional intentionally to indicates that it may return null.

As mentioned, works differently when useDeprecatedV14Bootstrapping is enabled. Also enabling eagerServerLoad flag makes UI available there, if I remember correctly.

As the message suggests, using UIInitiListener is preferred.

See #6939

@Artur-
Copy link
Member Author

Artur- commented Feb 24, 2022

Can we remove it then if it does not work by default?

@Legioth
Copy link
Member

Legioth commented Feb 24, 2022

We would still need something for the non-default cases that need it. Maybe just deprecating?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

4 participants