Условно включить / отключить p:selectManyMenu на основе значения h:selectOneRadio

У меня есть 2 радио кнопки, одна включить и отключить. Если я нажму на "Включить", все теги selectmanymenu должны быть отключены, и наоборот. не могли бы вы мне помочь. я приложил код ниже.

код радиокнопки:

<div>
    <h:selectOneRadio value="#{userData.data}" layout="pageDirection" id="filterGroup"
     required="true"  styleClass="control-group searchFilterRow searchFilterFont floatL" >
        <f:selectItem itemValue="1" itemLabel="By Part" />
        <f:selectItem itemValue="0" itemLabel="By Filter" />
    </h:selectOneRadio>
    </div> 

    <div class="floatL filterSection">
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5"
            columnClasses="label, value">

            <p:outputLabel styleClass="disblock" for="display11" value="Vehicle Programs:" />
            <div class="controls">
                <p:selectManyMenu id="display11"
                    value="#{selectManyView.selectedThemes}" converter="themeConverter"
                    var="t" filter="true" filterMatchMode="contains"
                    showCheckbox="true" styleClass="selectManyContainer"  disabled="#{(userData.data==1)}" >
                    <f:selectItems value="#{selectManyView.themes}" var="theme"
                        itemLabel="#{theme.displayName}" itemValue="#{theme}" />

                    <p:column>
                        <h:outputText styleClass="ui-theme ui-theme-#{t.name}" />
                    </p:column>

                    <p:column>
                        <h:outputText value="#{t.displayName}" />
                    </p:column>
                </p:selectManyMenu>
            </div>
        </h:panelGrid>
</div>
        <div class="floatL  filterSection">
        <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5"
            columnClasses="label, value">


            <p:outputLabel for="advanced" value="CSS:" />
            <div class="controls">
                <p:selectManyMenu id="advanced"
                    value="#{selectManyView.selectedThemes}" converter="themeConverter1"
                    var="t" filter="true" filterMatchMode="contains"
                    showCheckbox="true" styleClass="selectManyContainer" disabled="#{(userData.data==1)}"  >
                    <f:selectItems value="#{selectManyView.themes}" var="theme"
                        itemLabel="#{theme.displayName}" itemValue="#{theme}"  />

                    <p:column>
                        <h:outputText styleClass="ui-theme ui-theme-#{t.name}" />
                    </p:column>

                    <p:column>
                        <h:outputText value="#{t.displayName}" />
                    </p:column>
                </p:selectManyMenu>
            </div>
        </h:panelGrid>

        <p:separator />

        </div>

Код бина:

package radioButton;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "userData", eager = true)
@SessionScoped

    public class UserData implements Serializable {

        private static final long serialVersionUID = 1L;

        public String data = "1";

        public String getData() {
            return data;
        }

        public void setData(String data) {
            this.data = data;
        }
    }

1 ответ

Вам нужно добавить компонент ajax в ваш selectOneRadio, чтобы обновить компоненты selectManyMenu.

<h:selectOneRadio value="#{userData.data}" layout="pageDirection" id="filterGroup"
 required="true"  styleClass="control-group searchFilterRow searchFilterFont floatL" >
    <f:selectItem itemValue="1" itemLabel="By Part" />
    <f:selectItem itemValue="0" itemLabel="By Filter" />
    <f:ajax render="display11 advanced"/> //id's of the selectManyMenu's
</h:selectOneRadio>

Или используйте <p:ajax update="display11 advanced"/> если вы собираетесь переключиться на <p:selectOneRadio> компонент вместо

Другие вопросы по тегам