I have multiple dropdown lists using Primefaces 5.0. As you select an option in the first drop down list (in this case a country) then it should grab the cities in that country and populate the city drop down list. However, I have code to populate my cities drop down list from my database using the country but the method is never called.
My Region.xhtml:
<h:form>
<p:tab title="Region Selection" rendered="true">
<p:panel header="Region Information">
<h:panelGrid columns="2" columnClasses="label, value">
<h:outputText value="Country" />
<p:selectOneMenu id="country" value="#{rosterBean.selectedCountry}">
<p:ajax listener="#{rosterBean.onCountryChange()}" update="state" />
<f:selectItem itemLabel="Select Country" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{rosterBean.countries}" />
</p:selectOneMenu>
<h:outputText value="State/ Province" />
<p:selectOneMenu id="state" value="#{rosterBean.selectedState}">
<p:ajax listener="#{rosterBean.onStateChange}" />
<f:selectItem itemLabel="Select State" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{rosterBean.states}" />
</p:selectOneMenu>
<h:outputText value="City" />
<p:selectOneMenu id="city" filter="true" filterMatchMode="contains" >
<f:selectItem itemLabel="Johannesburg" itemValue="0" noSelectionOption="true" />
<f:selectItem itemLabel="Pretoria" itemValue="1" noSelectionOption="true" />
</p:selectOneMenu>
</h:panelGrid>
</p:panel>
</p:tab>
</h:form>
My Bean:
@ViewScoped
@ManagedBean
public class RosterBean implements Serializable {
public void onCountryChange() {
System.out.println("Updating State");
}
}
I have got all my getters and setters, but that system.out is never called. So irrespective if it is going to call the right cities in that country it never gets there.