@Meta tag for views?

Folks, it looks like @Meta tag can only be used with AppShellConfigurator which doesn’t make sense because is per page. If I add @Meta to a view, I get an exception:

Found app shell configuration annotations in non AppShellConfigurator classes.
Please create a custom class implementing AppShellConfigurator and move the following annotations to it:
- @Meta from com.myapp.MyListView

Looking through Vaadin code, com.vaadin.flow.server. AppShellRegistry.validateClass() exempts PageTitle from being allowed in AppShellConfigurator only, but it doesn’t do the same for @Meta. Is it a bug or a feature?

public String validateClass(Class<?> clz) {
String error = null;

    List<Class<?>> validOnlyForAppShell = (List) getValidAnnotations();
    // PageTitle can be in AppShell and Views
   ** validOnlyForAppShell.remove(PageTitle.class);**
    if (WebComponentExporter.class.isAssignableFrom(clz)) {
        // Webcomponent exporter should have the theme annotation
        // and Push annotation as it is not appShell configured.
        validOnlyForAppShell.remove(Theme.class);
        validOnlyForAppShell.remove(Push.class);
    }

    String offending = getClassAnnotations(clz, validOnlyForAppShell);
    if (!offending.isEmpty()) {
        error = String.format(AppShellRegistry.ERROR_LINE, offending,
                clz.getName());
    }
    return error;
}

Meta tags on views are not supported, because the “outer shell” is not updated (except the title) by the router.

Open issue here https://github.com/vaadin/flow/issues/3383

Hi @observant-quetzal , you can solve this with javascript , will be much easier and cleaner :

private void setMetaTag(String content) {
UI.getCurrent().getPage().executeJs(“document.querySelector(‘meta[name="description"]’).setAttribute("content", " + content +”);");
}