JSP Iterating over a map of a list when the value might be null
- by Brian Hoover
How do I clear the value from the stack of a s:iterator?
I'm trying to iterator over a TreeMultimap with a structure like:
TreeMultimap<person, lineItems> persons;
Using something like:
<s:iterator value="attendeesForParticipantTypeEvents.asMap()">
<div>
<s:property value="key.name" /><br />
<s:iterator id="currentSku" value="value">
<s:property value="currentSku.name" /><br />
</s:iterator>
</div>
</s:iterator>
This works fine, except when the treeMultimap has null for lineItems, then it's taking the value from the previous iteration.
So, a structure like:
persons = {{"Person1",["Line1","line2"]},
{"Person2",["Line3","line4"]},
{"Person2",null}}
Renders as:
<div>
Person1<br />
Line1<br />
Line2<br />
</div>
<div>
Person2<br />
Line3<br />
Line4<br />
</div>
<div>
Person3<br />
Line3<br />
Line4<br />
</div>
Which seems to indicate that the value isn't being cleared on each iterator. What do I need to do to handle the case where value might be null?
Thanks for your help