I am trying to filter the collection using Thymeleaf by following the example in the following url. "Projection & selection on collection" section. http://doanduyhai.wordpress.com/2012/04/14/spring-mvc-part-iv-thymeleaf-advanced-usage/
<tr th:each="artist,rowStat : ${listArtits.?[alive == true]}">
...
</tr>
However I would like to use another property instead of fixed value (true/false). For example
<tr th:each="artist,rowStat : ${listArtits.?[played > playedCountReq]}">
...
</tr>
where as playedCountReq is another form variable available to Thymeleaf. I get the following error. Property or field 'playedCountReq' cannot be found on object of type ...
I tried multiple ways but no success. Any suggestions?
Within the selection filter, unqualified properties are relative to the element of the collection being filtered. But, the variable
#root
is always defined to be the root context object. This is how you can refer to variables at the root level from within the selection filter.Refer to "The #this and #root variables" section in the Spring EL documentation for more information.
I succeded :) Here is solution:
in controller:
in html:
Output:
Hope this help