How to enable my radiobutton with primefaces

1k Views Asked by At

enable/disable my selectOneRadio does not work like expected. It only activates after a "submit" and the ajax-direct approach does not work.

enter image description here

When I change the selection (click) to "Group", then the dropDown after the selection keeps being "disabled". It only appears after a "submit", but I like to have direct-ajax function.

<div>
<p:outputPanel id="customPanel" style="margin-bottom:10px">
    <p:selectOneRadio id="locationType" value="#{bean.query.locationType}"
        required="true" layout="custom">
        <f:ajax render="locationGroup locationOrganization">
            <f:selectItems value="#{bean.locationTypeSelectItems}"
                           var="locationTypeItem" itemValue="#{locationTypeItem}" itemLabel="#{msgs[locationTypeItem.label]}" />
        </f:ajax>
    </p:selectOneRadio>

    <h:panelGrid columns="3" cellpadding="5">
        <p:radioButton id="option1" for="locationType" itemIndex="0" />
        <p:outputLabel for="locationGroup" value="Group"/>
        <p:autoComplete id="locationGroup"
                        value="#{bean.query.locationGroup}"
                        completeMethod="#{bean.completeGroups}"
                        var="group"
                        itemLabel="#{group.description}"
                        itemValue="#{group}"
                        converter="org.company.project.presentation.group.GroupConverter"

                        maxResults="10"
                        dropdown="true"
                        cache="true"

                        disabled="#{bean.locationGroupDisabled}"/>

        <p:radioButton id="option2" for="locationType" itemIndex="1" />
        <p:outputLabel for="locationOrganization" value="#{msgs.pat_Organization}"/>
        <p:autoComplete id="locationOrganization"
                        value="#{bean.query.locationOrganization}"
                        completeMethod="#{bean.completeOrganizations}"
                        var="organization"
                        itemLabel="#{organization.name}"
                        itemValue="#{organization}"
                        converter="org.company.project.presentation.organization.OrganizationConverter"

                        maxResults="10"
                        dropdown="true"
                        cache="true"

                        disabled="#{bean.locationOrganizationDisabled}"/>

        <p:radioButton id="option3" for="locationType" itemIndex="2" />
        <p:outputLabel value="All" />

    </h:panelGrid>
    <p:message for="locationGroup" />
    <p:message for="locationOrganization" />
</p:outputPanel>
<p:message for="locationType" />

That's all folks!

0

There are 0 best solutions below