I have a thymeleaf html page that shows all rows from a database @Entity.
Problem: the entity has a complex field that is mapped with a hibernate AttributeConverter. When I want to show the field as String in html, I have to call that converter to onvert the complex field to a string representation, like:
<td th:text="${{T(org.exmaple.domain.utils.AddressConverter).convertToString(row?.address)}}" />
With source:
//assume I have the address only in this format
public class AddressConverter<Address, String> {
public String convertToString(Address address) {
if (address == null) return null;
return address.getZip() + " " + address.getTown();
}
}
Question: how can I optimize those utility imports in thymeleaf? I'm looking for something simple like:
<td th:text="${{addressUtil.convertToString(row?.address)}}" />