在下拉列表中选择禁用复选框

时间:2014-05-07 08:20:04

标签: javascript ajax jsf checkbox drop-down-menu

我在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")) {
        }
}

有谁知道如何实现这一目标?

由于

1 个答案:

答案 0 :(得分:1)

尝试以下代码:

<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 }
}

它应该在这里工作。