Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@PageTitle not working on vaadin-quarkus #67

Open
segersb opened this issue Feb 23, 2022 · 5 comments
Open

@PageTitle not working on vaadin-quarkus #67

segersb opened this issue Feb 23, 2022 · 5 comments

Comments

@segersb
Copy link

segersb commented Feb 23, 2022

The @PageTitle annotation is looked up on the route target class by Vaadin

    private static Optional<PageTitle> lookForTitleInTarget(Component routeTarget) {
        return Optional.ofNullable(routeTarget.getClass().getAnnotation(PageTitle.class));
    }

However, when using Quarkus the route target is a proxy subclass.
Since the @PageTitle annotation is not inherited, the annotation is not found.

I was able to fix the issue by overriding the Vaadin @PageTitle annotation and adding @inherited

@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface PageTitle {
    String value();
}
@TatuLund TatuLund transferred this issue from vaadin/framework Feb 24, 2022
@caalador caalador transferred this issue from vaadin/flow Mar 2, 2022
@caalador caalador added bug Something isn't working investigation labels Mar 2, 2022
@caalador
Copy link
Contributor

caalador commented Mar 2, 2022

I noted that running the project using java -jar target/quarkus-app/quarkus-run.jar the page title was set as expected, but not when running mvn quarkus:dev

@mcollovati
Copy link
Contributor

It seems that in dev mode all beans are intercepted by Quarkus for monitoring, so this is why page title may work when running the production jar, but not in dev mode.
Monitoring can be disabled in dev mode (https://quarkus.io/guides/cdi-reference#quarkus-arc_quarkus.arc.dev-mode.monitoring-enabled), but the problem may persist if the component is intercepted for other reasons.

Maybe instead of making @PageTitle inheritable, we can refactor AbstractNavigationStateRenderer.lookForTitleInTarget(...) (and similar cases) in Flow to make use of Vaadin's AnnotationReader.getAnnotationFor(...), that searches for the annotation on the whole class hierarchy.

@MarcinVaadin
Copy link
Member

MarcinVaadin commented Dec 5, 2022

According to vaadin/flow#2590:

Also there is AnnotationReader class which contains utility methods for reading annotation and it seems even read title methods.

Title should only be taken from the activated navigation target and parents should not be taken into account.

Somehow similar case but with HasDynamicTitle has been discussed in vaadin/flow#13871

@ErrorProne
Copy link

ErrorProne commented Jul 4, 2023

Side note: Since this doesn't seem to be fixed any time soon, it should get a note in the "known Issues" section: https://vaadin.com/docs/latest/integrations/quarkus/#quarkus.vaadin.knownissues
I've searched for quite a long time to get this working until I started to suspect a bug in integration, which I guess, is not the first thing most devs will assume.

@mcollovati
Copy link
Contributor

mcollovati commented Jul 5, 2023

@ErrorProne thanks for pointing out. This should definitely be documented until we can have it properly fixed.
I created an issue (vaadin/docs#2550) in the docs repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Development

No branches or pull requests

5 participants