0
Good morning friends! I am a beginner in Java and am trying to develop a system for church management. After many attempts, I can make ajax work, but I am not able to recover the id of the state that was selected in selectOneMenu. The returned id is always null. Follows snippets of the code:
<h:form id="formMembroCadastro">
<h:panelGrid id="panel2" columns="4">
<p:outputLabel for="estado" value="Estado: "
style="margin-left: 30px" />
<p:selectOneMenu id="estado" value="#
{membroBean.membro.endereco.bairro.cidade.estado}"
readonly="#{membroBean.acao == 'Consultar'}">
<p:ajax listener="#{membroBean.getCidadesDoBanco}"
immediate="true" update=":formMembroCadastro:cidade" />
<f:selectItem itemValue="" itemLabel="Escolha o estado"
noSelectionOption="true" />
<f:selectItems value="#{membroBean.estados}" var="estado"
itemValue="#{estado.id}" itemLabel="#
{estado.nome}" />
</p:selectOneMenu>
</h:panelGrid>
</h:form>
I’ve changed a lot of things, like @Viewscoped, @Sessionscoped, Event, Listener, update.
@ManagedBean
@ViewScoped
public class MembroBean implements Serializable {
private static final long serialVersionUID = 1L;
private Membro membro = new Membro();
private Estado estado;
public void getCidadesDoBanco() {
System.out.println(estado.getId());
cidades = new DAO<Cidade>(Cidade.class).listaGeral();
}
}
When I put
System.out.println(Estado.class);
prints "class br.com.igreja.modelo.Estado".
From now on I thank anyone who can help.
I found that the following error is occurring: "Conversion error when setting the value '3' to 'null Converter". Where the value 3 is the id of the selected state.
– Everton Guerreiro