I need to do the following
<tr th:fragment="rowFragment(rowObject)">
<td th:each="cellObject : ${rowObject.getCellObjects()}" th:replace="~{::cellFragment(${cellObject})}"></td>
</tr>
In leymans terms for each object in a list construct a new cell. Each cell itself is formed via a thymleaf fragment hence th:replace with th:each.
I noticed that this code does technically “work” with th:each and th:insert, however these two in conjunction cause Thymeleaf to render the first defined in the alongside the fragment (essentially resulting in two elements when there only needs to be one. Hence my desire to use th:replace.
However th:replace along side th:each causes weird null pointer exceptions that I am unable to pinpoint. My best guess is that th:replace removes the th:each from the element(and thus the rowObject variable) and then attempts to pass such void/null rowObject into the fragment causing the null pointer error.
any suggestions?