TemplateRenderer works in development but NO in production

Hi,

I am using V14, I have this TemplateRenderer as test:

    private TemplateRenderer<SomeClass> test() {

        JsonFactory jsonFactory = new JreJsonFactory();

        return TemplateRenderer.<SomeClass>of(
                        "<vaadin-avatar-group maxItemsVisible=\"3\" items=[[item.data]]></vaadin-avatar-group>"
                ).
                withProperty("data", r -> {

                    JsonObject jsonObject1 = jsonFactory.createObject();
                    jsonObject1.put("name", "Foo Bar");

                    JsonObject jsonObject2 = jsonFactory.createObject();
                    jsonObject2.put("name", "Bar Foo");

                    return List.of(jsonObject1, jsonObject2);
                });
    }

This works fine in development mode, I see the two avatars in the group with FB and BF.
Inspecting with chrome I get (just copying a part to give an idea):

<vaadin-avatar-group maxitemsvisible="3" aria-label="Currently 2 active users"></vaadin-avatar-group>

then more data about what is in the cell.

In production mode after compiling with mvn clean package -Pproduction I don’t have any avatar in the column, the cell is empty.
Inspecting with chrome I see:

<vaadin-avatar-group maxitemsvisible="3"></vaadin-avatar-group>

It’s like it’s not renderer.

I don’t know the cause… and why it behaves in a different way.

Thanks for the help

It behaves differently because production mode can’t know you have used the classes in string literals. You have to add the annotation “@Uses” containing the avatar (group) to your class

Thanks you I resolved using @Uses(AvatarGroup.class) but it’s a bit strange, in another view I have another table where I use just

<vaadin-avatar name=[[item.name]] img=[[item.img]]</vaadin-avatar>

and this works, without any @Uses annotation

last question on this, still about avatar group, do I need the @Uses(Avatar.class) too where I have the avatar group? It seems no but I prefer to ask.

thanks

It’s possible that some other Vaadin component has a dependency on avatar and therefore it works. Personally I would add both classes, but I don’t think it’s necessary

ok!