I have a problem witn the lit renderer, when trying to render a list. In the following code the ${topic.name} and ${topic.color} are not replaced by the correct values (instead the values are undefined), and I do not know why? I know I have to remove the join and replace it by html, but currently I just want that the two placeholders are correctly replaced. The System.out.printn return the correct values. Can someone probably help me?
public static Renderer<PTask> createTaskSubjectRendererNotWorking(OrganizationUser organizationUser, Locale locale) {
//g -> g.getGroup() != null ? g.getGroup().getName() : ""
return LitRenderer.<PTask> of(
"<vaadin-vertical-layout style=\"line-height: var(--lumo-line-height-m);\">"
+ " <span> ${item.subject} </span>"
//+ " <div style='display: flex; gap: 4px;'>"
+ " ${item.topics.map((topic) => "
+ " '<span style=\""
+ " background-color: ${topic.color};\""
+ " title=\"${topic.name}\">"
+ " ${topic.name}"
+ " </span>').join('')}"
+ " </div>"
+ " </vaadin-vertical-layout>")
.withProperty("subject", p -> p.getTaskSubject())
//.withProperty("assignedTo", p -> getAssignedToString(p))
.withProperty("topics", p -> {
List<Map<String, String>> topics = p.getTopics(organizationUser).stream()
.map(topic -> Map.of(
"color", topic.getColor(),
"name", topic.getTopic()))
.toList();
System.out.println("Topics: " + topics); // Log für Debugging
return topics;
});
}
Thank you!
Florian