【问题标题】:Loop through hashmap and use key to access another hashmap within遍历 hashmap 并使用 key 访问其中的另一个 hashmap
【发布时间】:2020-05-06 06:15:04
【问题描述】:

我正在构建一个包含几个 selectmanycheckboxes 的 liferay jsf portlet。对于每个 selectcheckbox 有 2 个列表。第一个用于存储可见元素,第二个包含选定元素。它应该是动态工作的,这就是为什么我将 selectmanycheckboxes 的列表存储在两个单独的哈希图中。

我正在循环显示要显示的数据的第一个哈希图(工作正常)。但是然后在 selectManyCheckbox 中,我想使用 foreach 循环中的键访问所选元素的第二个 Hashmap(这不起作用)。

有没有办法从第一个键中访问第二个 Hashmap?

<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> 

【问题讨论】:

标签: jsf hashmap xhtml jstl


【解决方案1】:

好的,我解决了我自己的问题。

解决办法:

foreach 循环的键必须是字符串类型,而不是整数。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-05-11
  • 2011-10-23
  • 1970-01-01
  • 1970-01-01
  • 2015-02-13
  • 2012-10-16
  • 2017-07-06
  • 1970-01-01
相关资源
最近更新 更多