I'm developing a program but ajax does not work at all. I decided to make a very simple system to see where the error is and even then I can not find a solution. I saw some errors of this in the forum but I could not. HTML
<h:outputText value="Pais: " />
<p:selectOneMenu id="comboPais" process="@this" converter="conversorObjetoId" value="#{comboMB.pais}">
<f:selectItem itemLabel="--Selecione--" itemValue="" />
<f:selectItems value="#{comboMB.paises}" var="pais" itemLabel="#{pais.nome}" itemValue="#{pais}" />
<p:ajax event="change" update="comboEstados" actionListener="#{comboMB.buscar()}" /> </p:selectOneMenu>
<h:outputText value="Estados: " />
<p:selectOneMenu id="comboEstados" value="#{vendasMB.estado}">
<f:selectItem itemLabel="--Selecione--" itemValue="" />
<f:selectItems value="#{vendasMB.estados}" var="estado" itemLabel="#{estado.nome}" itemValue="#{estado}" />
</p:selectOneMenu> </h:panelGrid> </p:panel> </h:form>
The index I changed several things already left onChange, ja took update, listener several attempts
@ViewScoped @ManagedBean
@PostConstruct
public void init() {
paises = dao.consultarPais();
System.out.println("--> init*()");
}
public void buscar(ActionEvent event) {
estados = dao.consultarEstados(pais);
}
UPDATED
<h:form id="frmTeste">
<p:outputPanel id="cadastroCidades">
<h:panelGrid id="painel" columns="2">
<p:outputLabel for="comboPaises" value="Pais: " />
<p:selectOneMenu id="comboPaises" converter="conversorObjetoId" value="#{comboMB.pais}">
<f:selectItem itemLabel="--Selecione--" itemValue="" />
<f:selectItems value="#{comboMB.paises}" var="pais" itemLabel="#{pais.nome}" itemValue="#{pais}" />
<p:ajax listener="#{comboMB.buscar}" update="comboEstados" />
</p:selectOneMenu>
<p:outputLabel for="comboEstados" value="Estados: " />
<p:selectOneMenu id="comboEstados" converter="conversorObjetoId" value="#{vendasMB.estado}">
<f:selectItem itemLabel="--Selecione--" itemValue="" />
<f:selectItems value="#{vendasMB.estados}" var="estado" itemLabel="#{estado.nome}" itemValue="#{estado}" />
</p:selectOneMenu>
</h:panelGrid>
</p:outputPanel>
</h:form>