Browser tab set caption, understand behavior(

Hi everyone, i’m try to set tab caption like (UI.getCurrent().getPage().setTitle(NAME)), from each active UI class at curent moment.
Example:

UISettings{
   getMenuItem(){
     UI.getCurrent().getPage().setTitle("Settings");
   }

}

UIConfigurations{
 getMenuItem(){
    UI.getCurrent().getPage().setTitle("Users");
   }
}

But always tab set the last item value(((

My execute code:

private HorizontalLayout getHorizontalMenu(){
        HorizontalLayout root = new HorizontalLayout();
        root.setSpacing(true);
        root.setClassName(THEME.padding);

        //Menu with items
        root.add(UIApplication.getMenuItem(), UIDictionaries.getMenuItem(), UIConfigurations.getMenuItem(), UISettings.getMenuItem());

        root.setVerticalComponentAlignment(Alignment.CENTER);

        return root;
    }

This code show UI.getCurrent().getPage().setTitle(NAME) only for last element. In my case it’s —>UISettings.getMenuItem().

I can’t be sure without seeing the rest of your code, but my guess is that your getMenuItem() method is only called once per menu item, on the line with root.add(UIApplication.getMenuItem(), .... This would mean that UISettings.getMenuItem() is called last and the page title is not changed since. You could verify this assumption easily by adding some logging or debugging. Instead, I’d suggest you change the title in, for example, a beforeEnter event handler of your Views.

Thanks,

Olli Tietäväinen:
I can’t be sure without seeing the rest of your code, but my guess is that your getMenuItem() method is only called once per menu item, on the line with root.add(UIApplication.getMenuItem(), .... This would mean that UISettings.getMenuItem() is called last and the page title is not changed since. You could verify this assumption easily by adding some logging or debugging. Instead, I’d suggest you change the title in, for example, a beforeEnter event handler of your Views.

Thanks, all works)

Great)