title: Iterate over hashmap in jsf
body: <p>I am stuck at this for the last couple days. I have a bean which has an <code>HashMap</code> whose map values are <code>objects</code>. I am trying to iterate over the map by converting it to list.</p>
  
  <p>If I do something like this
  In bean</p>
  
  <pre><code>List&lt;Map.Entry&lt;String, List&lt;Objects&gt;&gt;&gt; entrySet = new ArrayList&lt;…&gt;map.EntrySet();
  </code></pre>
  
  <p>And in xhtml:</p>
  
  <pre><code>&lt;p:datatable var=”obj” value=”#{bean.entrySet}”&gt;&gt;
    &lt;p:columnGroup&gt;
      &lt;p:row&gt;
        &lt;ui:repeat var=”values” value=”#{obj.value}”&gt;
            &lt;p:column headerText=”#{values.xyz}” /&gt;
        &lt;/ui:repeat&gt;
     &lt;p:row&gt;
    &lt;/p:columnGroup&gt;
  &lt;/p:datatable&gt;
  </code></pre>
  
  <p>It shows an empty column</p>
  
  <p>However, if I do something like this:
  In bean</p>
  
  <pre><code>List&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
  </code></pre>
  
  <p>And in xhtml:</p>
  
  <pre><code>&lt;p:datatable&gt;
  …
     &lt;ui:repeat var=”values” value=”#{bean.list}”&gt;
     …
     &lt;/ui:repeat&gt;
  …
  &lt;/p:datatable&gt;
  </code></pre>
  
  <p>It works. What I don't understand is that the value of hashmap is the list of objects. If I iterate over the values which is a list, why didn't it work?</p>
  
  <p>I would really appreciate if someone can tell me what's wrong with my first approach. I can use the second one but it going to require major changes in the bean.</p>
  
  <p>I have already seen below questions but couldn’t resolve my issue</p>
  
  <p><a href="https://stackoverflow.com/questions/6001743/how-to-show-hashmap-values-in-jsf">How to show hashmap values in jsf?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/25658034/primefaces-static-and-dynamic-columns-in-datatable">Primefaces static and dynamic columns in datatable</a></p>
  
  <p><a href="https://stackoverflow.com/questions/13970285/creating-and-populating-a-datatable-dynamically-in-jsf2-0/13970491#13970491">Creating and populating a DataTable dynamically in JSF2.0</a></p>
  
  <p><a href="https://stackoverflow.com/questions/18867345/how-to-display-variable-number-of-columns-in-primefaces-datatable">How to display variable number of columns in primefaces datatable</a></p>