Dynamic page title for

In my AppLayout, I want to have a dynamic viewTitle for the same view implementing the HasDynamicTitle interface. However, it seems like the afterNavigation only gets called when navigating to a different view class?

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

private String getCurrentPageTitle() {
    String title = (String) VaadinSession.getCurrent().getAttribute("title");
    return title == null ? "" : title;
}`

That’s correct, you have to call it yourself if you wanna change the title “on the fly” without changing views

And how to call it with this class def

@Route(value = "applications", layout = MainLayout.class) public class ApplicationsView extends VerticalLayout implements HasUrlParameter<String>, HasDynamicTitle

Page.getCurrent().setTitle(string)

Yes, that works but the viewTitle for the appLayout needs to change accordingly and since the afterNavigation isn’t called even after re-navigating to the same view, the viewTitle doesen’t change

Navigating to the same does not trigger the full navigation circle and therefore the needed events aren’t thrown. An alternative could be to use findAncestor(YourMainlayout.class).doStuff();

I think you can use AfterNavigationObserver: Navigation Lifecycle | Routing & Navigation | Vaadin Docs it’s different than afterNavigation() in the MainLayout

ohh… good eyes :+1: that’s the wrong method…

Yes, that works - completely missed that :joy:
Thanks !