In my domain I have a Commessa
that contain a List of programmazioneTransient
that contain a list of varieTransient
.
With thymeleaf I create a view that show every element of the second list, and run perfectly. Now I added the loop for showing the list of varieTransient but I have this error:
Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "programmazioneTransient+${prgStat.index}.varieTransient" (template: "views/programmazione/show" - line 92, col 19) at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.attoparser.MarkupParser.parse(MarkupParser.java:257) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ~[thymeleaf-3.0.8.RELEASE.jar:3.0.8.RELEASE] ... 102 common frames omitted Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "programmazioneTransient+${prgStat.index}.varieTransient" (template: "views/programmazione/show" - line 92, col 19) at org.thymeleaf.spring4.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:290) ~[thymeleaf-spring4-3.0.8.RELEASE.jar:3.0.8.RELEASE]
My html page is the follow:
<th:block th:each="prg, prgStat : *{programmazioneTransient}">
<tr th:id="riga+${prgStat.index}">
<td scope="col" style="width: 15%!important;">
<input type="text" th:id="sperimentatore+${prgStat.index}" th:name="programmazioneTransient[+${prgStat.index}+].sperimentatore" class="text-center form-control-plaintext" readonly="readonly" th:value="${#strings.capitalizeWords(prg.sperimentatoreTransient)}"></input>
</td>
<td scope="col" style="width: 15%!important;">
<input type="text" th:id="aiutoSperimentatore+${prgStat.index}" th:name="programmazioneTransient[+${prgStat.index}+].aiutoSperimentatore" class="text-center form-control-plaintext" readonly="readonly" th:value="${#strings.capitalizeWords(prg.aiutoSperimentatoreTransient)}"></input>
</td>
...
<th:block th:each="v, vInd : *{programmazioneTransient+${prgStat.index}.varieTransient}" >
<td scope="col" >
<input type="number" th:id="v.quantita+*{#lists.size(programmazioneTransient)}" th:name="varieTransient[+${vInd.index}+].numeroProgrammate" class="text-center form-control-plaintext" readonly="readonly" th:value="varieTransient[+${vInd.index}+].numeroProgrammate"></input>
</td>
</th:block>
</tr>
</th:block>
Any suggestion?
Instead of trying to index, why not just use the local variable?
<th:block th:each="prg, prgStat : *{programmazioneTransient}">
.
.
.
<th:block th:each="v, vInd : ${prg.varieTransient}">
.
.
.
</th:block>
</th:block>
If you do want to use the index, you should remember that in general, you shouldn't nest ${...}
expressions -- except in special cases. That expression would look like this:
<th:block th:each="v, vInd : *{programmazioneTransient[prgStat.index].varieTransient}">
.
.
.
</th:block>