0

I'm building a liferay jsf portlet which contains a few selectmanycheckboxes. For each selectcheckbox there are 2 lists. The first one is for storing the visible elements, and the second one contains the selected elements. It should be work dynamically, that's why I stored the Lists for the selectmanycheckboxes in two separate hashmaps.

I'm looping through the first hashmap for the data to display(work's fine). But then in the selectManyCheckbox I want to access the second Hashmap for the selected Elements with the key from the foreach loop (that's not working).

Is there a way to access the second Hashmap within the key from the first one?

<c:forEach var="column" items="#{ListView.columns}">
    <td>
        <div>
            <div style="margin-bottom:1em;">
                <h3>Column #{column.key}</h3>
                <p:commandButton value="Hinzufügen" actionListener="#{ListView.addFromSelected}" update="@form">
                    <f:attribute name="destination" value="#{column.key}" />
                    <f:attribute name="origin" value="0" />
                </p:commandButton>
            </div>
            <table>
                <tr>
                    <td>
                        <div style="background-color:white; border:1px solid lightgray; overflow-y:scroll; min-height:200px; max-height:200px;">
                            <p:selectManyCheckbox value="#{ListView.selectedColumns[column.key]}" layout="grid" columns="1">
                                 <f:selectItems value="#{column.value}" var="block" itemLabel="#{block.name}" itemValue="#{block.id}" />
                            </p:selectManyCheckbox>
                        </div>
                    </td>
                </tr> 
           </table>
       </div>
    </td>
</c:forEach> 
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • Does this answer your question? [EL access a map value by Integer key](https://stackoverflow.com/questions/924451/el-access-a-map-value-by-integer-key) – Kukeltje Jan 20 '20 at 12:37

1 Answers1

-1

Okay I solved my own problem.

The solution:

The keys for the foreach loop have to be type string, not integer.

  • 1
    This is not needed... See https://stackoverflow.com/questions/924451/el-access-a-map-value-by-integer-key – Kukeltje Jan 20 '20 at 12:38