jsf - 我有 4 个复选框,c1、c2、c3 和 c4。如果选择了 c1,那么 c4 将被自动选择。我如何在 jsf 中实现这一点?
问题描述
我有 4 个复选框。我想做配对选择(选择 1 个复选框,然后自动选择另一个复选框)。checkbox1 将与 checkbox4 配对。checkbox2 将与 checkbox3 配对。
xhtml(将显示 4 个复选框):
<p:dataTable id="popup1" var="comp1" rows="10"
value="#{ExaBackingBean.managedBean.popupcomp1List}"
editable="true"
selection="#{ExaBackingBean.managedBean.popupcomp1Select}"
emptyMessage="#{lbl['lbl.datatable.msg.no.records.found']}"
rowKey="#{comp1.documentId}" rowIndexVar="index">
<ac:paginator for="popup1"></ac:paginator>
<p:column style="width:3px;text-align:center;" >
<p:selectBooleanCheckbox value="#{comp1.selected}">
<p:ajax listener="#{ExaBackingBean.ckechboxSelectPairingAction(comp1.documentId)}" partialSubmit="true" process="@this" update="@([id$=CompChecklist])" />
</p:selectBooleanCheckbox>
</p:column>
public void ckechboxSelectPairingAction(int documentId) throws Exception {
System.out.println("documentId xxxxxxxxxxxx"+documentId);
if (documentId == 1) {
// ---> checkbox1 & checkbox4 should be selected, how to check the checkbox1 & 4?
} else if(documentId == 2) {
System.out.println("documentId kat dalam"+documentId);
// ---> checkbox2 & checkbox3 should be selected
}
解决方案
推荐阅读
- javascript - 当第一次是字符串时,Number() 不适用于 .reduce()
- php - if 语句将页面变为白色
- php - 关系有问题,找不到属性
- css - 为什么我不能让我的 css 在 mamp 中渲染?
- c++ - 我的 SDL_ttf 渲染文本最终被拉伸。我该如何避免呢?
- java - 当涉及到 Firestore 中的定价时,对文档的查询是如何工作的?
- c - makefile 的问题,没有生成目标的规则 [C]
- cookies - 表单提交后设置cookie
- c++ - 文件 wx/wx.h 不存在
- burp - 构建 BURP 扩展时如何从 processHttpMessage 的响应中获取 URL?