thymeleaf 3 issue with nested lists//nested maps?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

thymeleaf 3 issue with nested lists//nested maps?

basically asking thymeleaf to "iterate" the map.value for each entry, I get an error complaining that "value" cannot be found on null.. If i use thymeleaf2.X this works perfectly though.. Then I assumed that something might have broken the "cast" from map.entry to a proper list.. I changed the code to be a List aBean with ContainerBean having a string tagAreaName and a List tiedValues adapted the html code
<tr th:each="instance,itr : ${aBean}">
	<td th:text="${instance.tagAreaName}" colspan="4" style="font-weight:bold">tagareaName</td>
	<tr th:unless="${instance == null}" th:each="ad : ${instance.tiedValues}">  
	<td th:text="${instance.tagAreaName}" colspan="4" style="font-weight:bold">tagareaName</td>                    								        	
        <td th:title="${ad.documentName}" th:text="${#strings.abbreviate(ad.documentName,90)}"></td>
        <td th:text="${ad.fileSubmitDate}"></td>							        
        <td style="text-align: center; vertical-align: middle;">
		    <a href="#" th:href="@{'/link/customDocumentation/detail?id=' + ${ad.id}}">
		    	<img style="vertical-align: baseline;" width="15" height="15" class="edit-user cursor-pointer" th:src="@{/img/glyphicons_150_edit.png}" />								    									
		    </a>								       	
        </td>	
	</tr>	
</tr>
and I receive the very same error now associated to "tiedFiles" attribute not being found on null (instance null) which shouldn't be possible in the first place given the th:unless="${instance == null}" I am at my wits end.. Did the nested loops behaviour change in thymeleaf 3? Because this was fully functional as of thymeleaf2... :/ Thanks in advance
witchedwiz
Hi all, I'm facing a curious problem.. given Map<String, List<ACertainBean>> aMap the following would work in thymeleaf2.X
<tr th:each="instance : ${aMap}">
	<td th:text="${instance.key}" colspan="4" style="font-weight:bold">keyvalue</td>
	<tr th:each="ad : ${instance.value}">
		<td></td>	                        								        	
        <td th:title="${ad.documentName}" th:text="${#strings.abbreviate(ad.documentName,90)}"></td>
        <td th:text="${ad.fileSubmitDate}"></td>							        
        <td style="text-align: center; vertical-align: middle;">
		    <a href="#" th:href="@{'/link/customDocumentation/detail?id=' + ${ad.id}}">
		    	<img style="vertical-align: baseline;" width="15" height="15" class="edit-user cursor-pointer" th:src="@{/img/glyphicons_150_edit.png}" />								    									
		    </a>								       	
        </td>	
	</tr>
</tr>
as of thymeleaf3, this seems not to be working anymore, and literally when cycling
Reply | Threaded
Open this post in threaded view
|

Re: thymeleaf 3 issue with nested lists//nested maps?

witchedwiz
anyone?
please note that the above post got "broken" by some stuff on the forum side..
instead of being
"Hi all, I'm facing a curious problem.. given Map<String, List<ACertainBean>> aMap the following would work in thymeleaf2.X
blablablalbalbalal
blalblalalblala2"
it's being presented as
"blalblalalblala2
Hi all, I'm facing a curious problem.. given Map<String, List<ACertainBean>> aMap the following would work in thymeleaf2.X
blablablalbalbalal"

oh well :X
Reply | Threaded
Open this post in threaded view
|

Re: thymeleaf 3 issue with nested lists//nested maps?

witchedwiz
This post was updated on .
up?
Am I the only one with this issue, or am I the only one using map of list // list of list with thymeleaf 3?
I'm quite unhappy of having to do some roundabout stuff for something that worked oob with thymeleaf 2..
Reply | Threaded
Open this post in threaded view
|

Re: thymeleaf 3 issue with nested lists//nested maps?

witchedwiz
uhm..
apparently using
tr:each nested with each other was working in thymeleaf2, with the nested loop being able to reference the first one..

e.g. this one worked with thymeleaf 2, doesn't with 3..
<tr th:each="instance : ${acerDocs}">
  <td th:text="${instance.key}" colspan="4" style="font-weight:bold">keyvalue</td>
  <tr th:each="ad : ${instance.value}">
     <td></td>	                        								        	
     <td th:title="${ad.documentName}" th:text="${#strings.abbreviate(ad.documentName,90)}"></td>
     <td th:text="${ad.fileSubmitDate}"></td>							        
     <td style="text-align: center; vertical-align: middle;">
         <a href="#" th:href="@{'/acer/acerDocumentation/detail?id=' + ${ad.id}}">
		<img style="vertical-align: baseline;" width="15" height="15" class="edit-user cursor-pointer" th:src="@{/img/glyphicons_150_edit.png}" /> </a>								       	
      </td>	
    </tr>
</tr>

<div th:each="instance  : ${acerDocsMap}" th:remove="tag">
  <tr>
    <td th:text="${instance.key}" style="font-weight: bold;"></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr th:each="documentAct : ${instance.value}">
    <td></td>
    <td th:title="${documentAct.documentName}" th:text="${#strings.abbreviate(documentAct.documentName,90)}"></td>
    <td th:text="${documentAct.fileSubmitDate}"></td>							        
    <td style="text-align: center; vertical-align: middle;">
      <a href="#" th:href="@{'/acer/acerDocumentation/detail?id=' + ${documentAct.id}}">
	<img style="vertical-align: baseline;" width="15" height="15" class="edit-user cursor-pointer" th:src="@{/img/glyphicons_150_edit.png}" /> </a>								       	
     </td>	
  </tr>
</div>

so basically in the first example, when using thymeleaf3, the nested loop has NO VISIBILITY (not even using the with) to the variable of the first loop.. instance.value resulted in a null-like error complaining that value was undeclared or non-existing on the instance object...

while I understand that thymleaf is a free product, having to adapt your previous implementation for some changes that was not documented in the migration guide was really a pain..
I hope the devs of thymeleaf don't take it personally, but that was really a poor approach...