• using the @PageTitle annotation

  • implementing HasDynamicTitle

Java

Note
The @PageTitle annotation is read from the actual navigation target only; neither its superclasses nor its parent views are considered.

Implementing the interface HasDynamicTitle allows us to change the title from Java at runtime:

  1. @Route(value = "blog")
  2. implements HasDynamicTitle, HasUrlParameter<Long> {
  3. private String title = "";
  4. @Override
  5. public String getPageTitle() {
  6. return title;
  7. }
  8. public void setParameter(BeforeEvent event,
  9. @OptionalParameter Long parameter) {
  10. title = "Blog Post #" + parameter;
  11. } else {
  12. title = "Blog Home";
  13. }
  14. }

See also: