Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Loop map with entity

Have some for:

for(int i = 0; i < ids.size(); i++){
            List<NomenclatureTypeFirst> nmtf = nomenclatureTypeFirstService.getAllByRequest(ids.get(i));
            map.put(ids.get(i), nmtf);
        }

Tried to uset th:text on value like this:

<table>
        <tr th:each="entry, stats : ${map}">
        <td th:text="${entry.key}"></td>
        <td th:text="${entry.value.detname}"></td>
        </tr>
    </table>

But catch:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Property or field 'detname' cannot be found on object of type 'java.util.ArrayList' - maybe not public or not valid?

How can I do this?

>Solution :

The value of your map is a list, so you have to iterate over the values:

<table>
    <tr th:each="entry, stats : ${map}">
    <td th:text="${entry.key}"></td>
    <table>
      <tr th:each="value : ${entry.value}">
         <td th:text="${value.detname}"></td>
      </tr></table>

    </tr>
</table>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading