Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterate over Guava Table with JSTL

Tags:

jsp

jstl

guava

I am using the Table class (specifically the HashBasedTable) from the Guava library (formerly Google Collections). I am using Spring MVC and after packaging my beans into this Table in my controller class, I want to iterate over it on my JSP page.

How would I go about doing that? Below is a simplified version of what I'd been trying.

  <c:forEach var="rowElement" items="${resultsCL.rowKeySet}">
      <c:forEach var="columnElement" items="${resultsCL.columnKeySet}">
          ${resultsCL.get(rowElement, columnElement)}">
       </c:forEach>
   </c:forEach>
like image 631
Steve Avatar asked Oct 10 '22 10:10

Steve


1 Answers

rowKeySet and columnKeySet are not getter-methods, so you can't call them with bean.property syntax. You need to invoke the methods. I.e. resultCL.rowKeySet() and resultCL.columnKeySet()

Note that this may not work with older versions of EL that do not support method invocations.

like image 59
Bozho Avatar answered Oct 13 '22 11:10

Bozho