First I retrieve the Note
objects in the service layer:
List<Note> notes = this.getNotes();
Then I pass List
of Notes
to the view layer and set the same initial value for prevNote
and currNote
to the first element of the List
:
<c:forEach items="${notes}" var="note" begin="0" end="1" step="1">
<c:set var="prevNote">${note}</c:set>
<c:set var="currNote">${note}</c:set>
</c:forEach>
Then I iterate over the List
and set prevNote
to currNote
and currNote
to the current note item (note
) from the loop:
<c:forEach items="${notes}" var="note">
<c:set var="prevNote">${currNote}</c:set>
<c:set var="currNote">${note}</c:set>
prev:<c:out value="${prevNote.userCode}"/>
curr:<c:out value="${currNote.userCode}"/>
</c:forEach>
But when I run this, I get this error message:
Unable to find a value for "note" in object of
class "java.lang.String" using operator ".
What I want to do here is check whether prevNote
and currNote
contain the same userCode
value - if they do I want to skip the current element in the List
and display the next Note
that has a different userCode
(sort of simulating a group-by
operation).
Any hints on how to do this and why I'm getting this error message?