Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterate Hashmap of object

 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am getting the problem to iterate the hashmap of objects.Follwing code works good for a vector but has some problem for HashMap. I know this is becuase hashmap key,value pair. Can any one correct it.



<logic-l resent name="AddTemplateForm" property="hmitemProperties">
<bean:size id="size"name="AddTemplateForm" property="hmitemProperties"/>
<b>Total No. of Template - <%=size%></b>
<logic-l:greaterThan name="size" value="0">
<logic-l:iterate id="itempro" name="AddTemplateForm" property="hmitemProperties">
<bean:write name="itempro" property="propertyName"/>

</logic-l:iterate>
</logic-l:greaterThan>
</logic-l resent>
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the information you want is in the key part of the hashmap, change the bean:write property to propertyName.key. If it is the value part of the hashmap that you want, use propertyName.value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic