Calling a method with a variable using spring-el from thymeleaf -


i have this:

<form action="/" th:object="${index}"> <ul class="error" th:if="${#fields.hasanyerrors()}" th:remove="all-but-first"> <li th:each="error : ${#fields.detailederrors()}" th:utext="${index.fielderrortext(error)}">detailed error</li> </ul> </form> 

calling ${index.fielderrortext(error)} works fine, want go step further. since have th:object="${index}" want able this:

*{fielderrortext(error)} 

but in case looks error on index rather th:each variable , throws "property or field 'error' cannot found".

i have tried other combinations: *{fielderrortext(${error})} (unexpected token. expected 'rparen())' 'lcurly({)'), *{fielderrortext(__${error}__)} (cannot handle (241) 'ñ'; seems tostring or something) , *{fielderrortext(__error__)} (property or field 'error' cannot found).

does know right semantics case?

try this

 *{fielderrortext(__${error}__)} 

according documentation need pre-processing.

http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#preprocessing


Comments