如果条件为true,则在用户选中selectBooleanCheckbox后立即取消选中该复选框
请原谅我的英语不好 我有一个带有2个选项卡的tabView,该选项卡具有由selectBooleanCheckbox呈现的可选选项,所以我做了:如果条件为true,则在用户选中selectBooleanCheckbox后立即取消选中该复选框,checkbox,primefaces,Checkbox,Primefaces,请原谅我的英语不好 我有一个带有2个选项卡的tabView,该选项卡具有由selectBooleanCheckbox呈现的可选选项,所以我做了: <p:selectBooleanCheckbox id="check" value="#{prestationComponent.prestation.condUnique}"> <p:ajax event="change" update="tabV"/> </p:selectBooleanCheck
<p:selectBooleanCheckbox id="check"
value="#{prestationComponent.prestation.condUnique}">
<p:ajax event="change" update="tabV"/>
</p:selectBooleanCheckbox>
<p:tabView id="tabV" orientation="top">
<p:tab title="#{refMessage_fr.taxe_condunique_title}"
rendered="#{prestationComponent.prestation.condUnique}">
</p:tab>
<p:tab title="#{refMessage_fr.taxe_formullelist_title}"
rendered="#{!prestationComponent.prestation.condUnique}">
</p:tab>
这工作做得很好
在其中一个tow选项卡中,我有一个列表,因此如果列表中有多个元素,我希望此选项卡处于活动状态,因此我将SelectBoolean复选框更改为:
<p:selectBooleanCheckbox id="check"
value="#{prestationComponent.prestation.condUnique}"
onchange="if(#{prestationComponent.addPrestationFormulesList.size()>1}) {PF('messageDialogue').show();#{prestationComponent.prestation.setCondUnique(false)};}">
<p:ajax event="change" update="tabV,check"/>
</p:selectBooleanCheckbox>
这与列表选项卡一起工作,它处于活动状态,但selectBooleanCheckbox保持选中状态
因此,如果(#{prestationComponent.addPrestationFormulesList.size()>1}),我希望选中BooleanCheckbox时保持未选中状态
多谢各位
===============================================================编辑====================================
我找到了解决方案,在托管bean中创建了一个函数来测试条件,如果条件为true,则将复选框的值设置为false,并在复选框的ajax事件的侦听器中调用它
<p:selectBooleanCheckbox id="check"
value="#{prestationComponent.prestation.condUnique}"
onchange="if(#{prestationComponent.addPrestationFormulesList.size()>1}) PF('messageDialogue').show();">
<p:ajax listener="#{prestationComponent.checkBoxListner()}" event="change" update="tabV,check"/>
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox id="check"
value="#{prestationComponent.prestation.condUnique}"
onchange="if(#{prestationComponent.addPrestationFormulesList.size()>1}) PF('messageDialogue').show();">
<p:ajax listener="#{prestationComponent.checkBoxListner()}" event="change" update="tabV,check"/>
</p:selectBooleanCheckbox>
我找到了解决方案,在托管bean中创建了一个函数,用于测试条件,如果条件为true,则将复选框的值设置为false,并在复选框的ajax事件的侦听器中调用它
<p:selectBooleanCheckbox id="check"
value="#{prestationComponent.prestation.condUnique}"
onchange="if(#{prestationComponent.addPrestationFormulesList.size()>1}) PF('messageDialogue').show();">
<p:ajax listener="#{prestationComponent.checkBoxListner()}" event="change" update="tabV,check"/>
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox id="check"
value="#{prestationComponent.prestation.condUnique}"
onchange="if(#{prestationComponent.addPrestationFormulesList.size()>1}) PF('messageDialogue').show();">
<p:ajax listener="#{prestationComponent.checkBoxListner()}" event="change" update="tabV,check"/>
</p:selectBooleanCheckbox>
当列表包含多个元素时,是否有理由不禁用复选框?是的,用户只能选择一个选项,列表中的一个元素或一个特定的公式(不能在列表中),如果他选择一个列表并填写它,如果他想更改为一个公式,则存在此条件(由我们的客户设置,我不知道为什么),如果列表包含多个元素,则用户不能更改为一个公式