我正在使用Primefaces 的SelectMany 复选框,并且在将值存储在 Bean 中时遇到了一些麻烦。
我需要一组 SelectManyCheck 框。这是到目前为止的xhtml,
<c:set var="obj" value="#{userBean.userSettingsMap}"> </c:set>
<c:forEach items="#{obj}" var="entry">
<h:outputText value="#{entry.key} " /><!--Correctly prints the key -->
<p:selectManyCheckbox value="#{entry.value}"><!-- `entry.value` SHOULD correspond to inner lists --->
<!-- I want values of these check boxes to be updated in my ManagedBean's property -->
<f:selectItem itemLabel="Option 1" itemValue="Option 1" />
<f:selectItem itemLabel="Option 2" itemValue="Option 2" />
<f:selectItem itemLabel="Option 3" itemValue="Option 3" />
</p:selectManyCheckbox>
</c:forEach>
Select Many 复选框的数组呈现在页面上。但是当我提交页面时,子列表没有更新。而是我的 ManagedBean 中的对象没有得到更新。
因此,在提交时,我会在对话框中显示空白列表。
{键 1=[],键 2=[]}
在我的 ManagedBean 中,
private Map<String,List<String>> userSettingsMap;
子列表将对应于 <p:selectManyCheckbox>
视图上的每个
提交按钮与示例中的相同。
<p:commandButton value="Submit" update="display" oncomplete="dlg.show()" />
<p:dialog header="Selected Values" modal="true" showEffect="fade" hideEffect="fade" widgetVar="dlg">
<p:outputPanel id="display">
<p:dataList value="#{userService.userMaintainceMap}" var="option">
#{option}
</p:dataList>
</p:outputPanel>