0

I created an app using the stub from start.vaadin.com. If I set the page title as an annotation it works:

enter image description here

However, when I set it using a HasDynamicTitle way, the app's header remains empty:

enter image description here

Could you please advise how can fix it? I'm using Vaadin Flow v.24.

Sogawa-sps
  • 147
  • 10

1 Answers1

1

It's because the header is read from the @PageTitle annotation. In MainLayout.java:

    private H2 viewTitle;

    // ...

    @Override
    protected void afterNavigation() {
        super.afterNavigation();
        viewTitle.setText(getCurrentPageTitle());
    }

    private String getCurrentPageTitle() {
        PageTitle title = getContent().getClass().getAnnotation(PageTitle.class);
        return title == null ? "" : title.value();
    }

You can check if the content object implements HasDynamicTitle and return a different String from getCurrentPageTitle in that case.

ollitietavainen
  • 3,900
  • 13
  • 30