是否有一些简单的方法可以根据selectBooleanCheckbox在selectOneMenu上切换禁用/启用
<p:selectBooleanCheckbox label="labelBox" onchange="(PF('SelectList').enable();" />
<p:selectOneMenu id="listUrgent" value="#{projectsControllerCreate.selected.listUrgent}" widgetVar="SelectList" >
答案 0 :(得分:1)
在bean中定义一个布尔值并将其绑定到p:selectBooleanCheckbox
。然后,设置ajax侦听器,以便根据该值更新p:selectOneMenu
状态。
<强> XHTML 强>
<p:selectBooleanCheckbox label="labelBox" value="#{projectsControllerCreate.selectionAllowed}">
<p:ajax event="change" update="listUrgent" />
</p:selectBooleanCheckbox>
<p:selectOneMenu id="listUrgent" value="#{projectsControllerCreate.selected.listUrgent}" disabled="#{!projectsControllerCreate.selectionAllowed}">
...
</p:selectOneMenu>
bean(projectsControllerCreate)
private boolean selectionAllowed;
public boolean isSelectionAllowed() {
return selectionAllowed;
}
public void setSelectionAllowed(boolean selectionAllowed) {
this.selectionAllowed = selectionAllowed;
}