Skip to content

Commit

Permalink
Also support PageTitle annotation in Layout
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Martinelli <[email protected]>
  • Loading branch information
simasch committed Oct 19, 2024
1 parent 2574655 commit 6f063b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/ch/martinelli/vj/ui/layout/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.vaadin.flow.component.sidenav.SideNav;
import com.vaadin.flow.component.sidenav.SideNavItem;
import com.vaadin.flow.router.HasDynamicTitle;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.server.StreamResource;
import com.vaadin.flow.server.auth.AccessAnnotationChecker;
import com.vaadin.flow.theme.lumo.LumoIcon;
Expand Down Expand Up @@ -120,7 +121,8 @@ private String getCurrentPageTitle() {
if (getContent() instanceof HasDynamicTitle hasDynamicTitle) {
return hasDynamicTitle.getPageTitle() == null ? "" : hasDynamicTitle.getPageTitle();
} else {
return "";
var title = getContent().getClass().getAnnotation(PageTitle.class);
return title == null ? "" : title.value();
}
}
}

0 comments on commit 6f063b8

Please sign in to comment.