3

I am stuck at this for the last couple days. I have a bean which has an HashMap whose map values are objects. I am trying to iterate over the map by converting it to list.

If I do something like this In bean

List<Map.Entry<String, List<Objects>>> entrySet = new ArrayList<…>map.EntrySet();

And in xhtml:

<p:datatable var=”obj” value=”#{bean.entrySet}”>>
  <p:columnGroup>
    <p:row>
      <ui:repeat var=”values” value=”#{obj.value}”>
          <p:column headerText=”#{values.xyz}” />
      </ui:repeat>
   <p:row>
  </p:columnGroup>
</p:datatable>

It shows an empty column

However, if I do something like this: In bean

List<Object> list = new ArrayList<Object>();

And in xhtml:

<p:datatable>
…
   <ui:repeat var=”values” value=”#{bean.list}”>
   …
   </ui:repeat>
…
</p:datatable>

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?

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.

I have already seen below questions but couldn’t resolve my issue

How to show hashmap values in jsf?

Primefaces static and dynamic columns in datatable

Creating and populating a DataTable dynamically in JSF2.0

How to display variable number of columns in primefaces datatable

Community
  • 1
  • 1
user4812502
  • 157
  • 1
  • 8

0 Answers0