40/5000 How to iterate over a nested object?

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

40/5000 How to iterate over a nested object?

silverwind
I want to display Product Entities that is in a many-to-many relation with the category.

My view
<nabble_embed><tbody> <tr data-th-each="product : ${products}"> <!--<td><input hidden="hidden" name="id" th:value="${product.id}" /></td>--> <td th:text="${product.name}"></td> <td th:text="${product.price}"></td> <tr th:each="category: ${product.categories}"></tr> <td th:text="${category.name}"></td> <td th:text="${product.description}"></td> <td th:text="${product.shippingWeight}"></td> <td th:text="${product.quantity}"></td> <td>delete</td> </tr> </tbody></nabble_embed>
           
 I have an error: Exception evaluating SpringEL expression "category.name" (productList: 31)
How resolve this problem?
Reply | Threaded
Open this post in threaded view
|

Re: 40/5000 How to iterate over a nested object?

Grzi (Jérémy Thulliez)
Hey, The problem is with the tr tag that you've closed too soon . Here, "category" is a local variable, accessible only in the loop made on the tag "tr". However, you use it outside the loop (your td is outside the tr), so it is actually impossible to evaluate the expression.