LitRenderer and Java records

As mentioned in the docs a lit template can handle nested properties. This seems not to work if the bean is a java record:

my lit template with a repeating template via map()

        String litLieferscheine = """
            ${item.lieferscheinInfos.map( (info) => html`
            <a href='/document/${info.documentId}' target='_blank'> <vaadin-icon icon='vaadin:file-table'/></a> ` ) }
        """;

        this.addColumn(LitRenderer.<MengenGridDto>of(litLieferscheine)
                .withProperty("lieferscheinInfos", dto -> dto.getLieferscheinInfos()))
            .setHeader("Lieferschein")
            .setAutoWidth(true)
            .setFlexGrow(0)
            .setResizable(true)
            .setSortable(false);

info maps to an instance of LieferscheinInfo due to dto.getLieferscheinInfos() is a List.

This only works if LieferscheinInfo is a class, e.g.

    @Data
    public static class LieferscheinInfo {
        private String nummer;
        private Integer documentId;
    }

It doesn’t work, if LieferscheinInfo is a java record:

public record LieferscheinInfo(String nummer, Integer documentId) {}

It this intentionally or accidently ?

Records are not really supported… they work sometimes but not in all cases… might be related to Support for serialization of record object to Json · Issue #16879 · vaadin/flow · GitHub

Suggestion: Create a ticket in Flow

2 Likes

Thanks @knoobie for your fast response …
I created the ticket

Thanks for the issue, @todo42 !

We have been working on Java Records support in Binder, Grid and CRUD. This ticket looks like a prerequisite for Grid, thanks.
Please follow the status of this ticket. Target release for Java Records support is 24.5 (or 24.6, if it would take much efforts).