title: Iterating through List<Map<String, String>> in primefaces datatable?
body: <p>I'm trying to iterate through a List of Map items, i.e. an ArrayList of HashMaps or something similar, and I'm trying to do this in primefaces datatable. This is basically what I'm trying to do: </p>
  
  <pre><code>&lt;body&gt;
      &lt;h:form&gt;
          &lt;p:dataTable value="#{customerBean.list}" var="map"&gt;
              &lt;c:forEach items="#{map}" var="entry"&gt;
                  &lt;p:column headerText="#{entry.key}"&gt;
                      #{entry.value}
                  &lt;/p:column&gt;
              &lt;/c:forEach&gt;
          &lt;/p:dataTable&gt;
      &lt;/h:form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>In this case, <code>customerBean.list</code> is a <code>List&lt;Map&lt;String, String&gt;&gt;</code> and entry is a <code>Map&lt;String, String&gt;</code>. </p>
  
  <p>What I want to do, is create a dynamic amount of columns, based on the amount of entries in a <code>Map&lt;String, String&gt;</code> while using the map entry's key as a header name, and the value as the output. The <code>c:forEach</code> thing seems to work fine when I'm using a hardcoded <code>Map&lt;String, String&gt;</code>, but apparently it can't loop through the var of the <code>p:dataTable</code>. I assume that the program takes precaution to avoid having to loop through Maps of different sizes. So how can I make this work anyway? How can I create an arbitrary amount of columns based on the amount of entries in a Map? Note that I'm a 100% certain that every <code>Map&lt;String, String&gt;</code> is of equal size in my <code>List&lt;Map&lt;String, String&gt;&gt;</code></p>
  
  <p>EDIT: </p>
  
  <p>Here's my bean source. The code works fine and everything, the problem is just with the loop not willing to go through my map: </p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class CustomerBean {
  
      private List&lt;Map&lt;String, String&gt;&gt; list = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
      private Mapper mapper = new Mapper();
  
      public CustomerBean() {
          list = mapper.all(); //gets data from database
      }
  
      public List&lt;Map&lt;String, String&gt;&gt; getList() { 
          return list;
      }
  
      public void setList(List&lt;Map&lt;String, String&gt;&gt; list) { 
          this.list = list;
      } 
  }
  </code></pre>