Quick question. This hasn\'t happened to me before when working with SelectOneMenu. This is my code.
If you are working objects in the value, check the equals() function.
I found the error and it was ... quite strange and circumstantial. I added the following line inside the SelectOneMenu:
<p:ajax event="change" update="@this" />
and now it works just fine.
I discovered when I had this problem it was because of the @ViewScoped
. Using SessionScoped
instead worked fine.
One interesting thing is that in another project, with ViewScoped
, it worked. I cannot explain.
<p:selectOneMenu id="listaRegiones" value="#{nuevaProvincia.regionSelect}" required="true">
<f:selectItems value="#{nuevaProvincia.regiones}" />
</p:selectOneMenu>
should be
<p:selectOneMenu id="listaRegiones" value="#{nuevaProvincia.regionSelect}" required="true">
<f:selectItems value="#{nuevaProvincia.regiones}" var="region"
itemValue = "#{region}"/>
</p:selectOneMenu>
That's why you have to have the ajax call to update whenever there is a change. You are never setting the value.