我需要selectManyCheckbox
在 4 列中显示列表,但问题是这个组件会生成一个表,所以我不知道如何定义列。
我正在使用 PF 3.4,无法升级到 PF 4.x。你们有什么解决办法吗?
已编辑
现在我的代码中有这个
<h:form id="formAdminAccesosXPerfil">
<h:panelGrid title="Accesos" columns="5">
<c:forEach items="#{accesosXPerfilMB.listadoAcceso}" var="availableItem" varStatus="loop">
<h:panelGroup>
<p:selectBooleanCheckbox id="box_#{loop.index}" value="#{accesosXPerfilMB.checkBoxItems[availableItem]}" />
<h:outputLabel for="box_#{loop.index}" value="#{availableItem.nombre}" />
</h:panelGroup>
</c:forEach>
</h:panelGrid>
@ViewScoped 的 Managebean
我更改了建议的方法,因为它对我不起作用...
从:
public void save() {
List<E> selectedItems = checkboxItems.entrySet().stream()
.filter(e -> e.getValue() == Boolean.TRUE)
.map(e -> e.getKey())
.collect(Collectors.toList());
// ...
}
对此:
public void guardarAccesos(){
try {
System.out.println("Size: "+getCheckBoxItems().entrySet().size());
for(BpAcceso acceso:getCheckBoxItems().keySet()){
System.out.println("Acceso Seleccionado: "+acceso.getNombre());
}
} catch (Exception e) {
e.printStackTrace();
}
}
但我没有在 hashMap 上得到任何选定的项目。只是为了确保我使用的是 jdk1.6