Primefaces Ajax listener is not getting called when rendered is used in Panel

561 views Asked by At

Below is the code snippet that is being used. When i remove the rendered attribute from the below code, the listener is getting called. but with render, its not calling the listener. My PrimaryContactHomeAddressBean bean is in RequestScope whereas AddressManagedBean is having ViewScope.

<p:outputPanel id="countyPanel">
            <p:panelGrid
                id="primaryContactHomeZipPanel" rendered="#{address.isMultipleCounty eq 'Yes'}">
                <h:outputLabel for="primaryContactHomeCounty">
                    </h:outputLabel>
                <p:selectOneMenu id="primaryContactHomeCounty"
                    value="#{addressManagedBean.countyName}">
                    <f:selectItems value="#{addressManagedBean.countyListDropdown}" />
                        <p:ajax listener="#{primaryContactHomeAddressBean.saveCountyName}" process="@this"  update="primaryContactHomecountyName" partialSubmit="true"></p:ajax>
                </p:selectOneMenu>
                <p:message for="primaryContactHomeCounty" />


            </p:panelGrid>
        </p:outputPanel>
2

There are 2 answers

0
Ninja On

I could solve this issue by moving isMultipleCounty variable to a ViewScoped Bean i.e. AddressManagedBean.

5
Evan Knowles On

This line does not follow the JavaBean standards.

rendered="#{address.isMultipleCounty eq 'Yes'}"

If the getter begins with is, then it is supposed to return a boolean, but here you are checking for a String. If it is returning a boolean, then remove the eq 'Yes', regardless rename it multipleCounty.