在xhtml文件中的数据表中有一个下拉框和一个复选框。下拉菜单有L, C, UV和其他各种选择。例如,当选中L时,我希望禁用复选框。
下面是下拉框和复选框的相关xhtml代码:<r2i4:selectForClass itemClass="VehicleGenericType" value="#{vc.vehicleGenericType}" rendered="#{vc.crudState == null || vc.crudState == 'CREATE'}"
valueChangedListener="#{vehicleCategory.vehicleDropdownChange">
<f:selectItems value="#{vehicleCategory.vehicleChanged}" />
<p:ajax />
</r2i4:selectForClass>
<f:facet name="input">
<p:selectBooleanCheckbox id="departmental" value="#{vc.isDepartmental}" rendered="#{vc.crudState == null || vc.crudState == 'CREATE'}"
disabled="#{vehicleCategory.vehicleChanged eq 'L'}"/>
</f:facet>
在bean中,我有以下代码:
public void vehicleDropdownChange(ValueChangeEvent e) {
if(e.getNewValue().equals("L")) {
}
}
有没有人知道我怎么才能做到这一点?
谢谢
试试下面的代码:
<r2i4:selectForClass itemClass="VehicleGenericType" value="#{vc.vehicleGenericType}" rendered="#{vc.crudState == null || vc.crudState == 'CREATE'}">
<f:selectItems value="#{vehicleCategory.vehicleChanged}" />
<p:ajax event="change" update="departmental" listener="#{vehicleCategory.vehicleDropdownChange} />
</r2i4:selectForClass>
<f:facet name="input">
<p:selectBooleanCheckbox id="departmental" value="#{vc.isDepartmental}" rendered="#{vc.crudState == null || vc.crudState == 'CREATE'}"
disabled="#{vehicleCategory.disable}"/>
</f:facet>
public void vehicleDropdownChange(ValueChangeEvent e) {
if ( .. ) { disable = true }
}
它应该在这里工作。