I've got a list box and I want to catch change in selection in order to fill an other one according to it. I've tried in the following way:
<h:selectOneMenu id="comunitaValle" value="#{struttura.nomeComunitaDiValle}"
onchange="submit()" valueChangeListener="#{struttura.getComuniInComunita}">
<f:selectItems value="#{struttura.comunitaValleList}" />
</h:selectOneMenu>
It works fine, but the fact that in this page there are other parameters marked as
required="true"
and when the form is submitted I get my error messages controlling that those field has been set. How can I avoid to submit the entire form to avoid this to happen and still have the correct behaviour on the 2 list boxes?
EDIT:
I've reached a kind of solution (don't know if it is the best one) according to https://stackoverflow.com/a/4802483/2492962 :
<h:selectOneMenu id="comunitaValle" value="#{struttura.nomeComunitaDiValle}"
valueChangeListener="#{struttura.getComuniInComunita}" immediate="true">
<a4j:support event="onchange" reRender="cap"/>
<f:selectItems value="#{struttura.comunitaValleList}" />
</h:selectOneMenu>
Can it be fine? JBoss shows a warning message:
INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
but the refresh seems fine.
I've reached a kind of solution (don't know if it is the best one) according to https://stackoverflow.com/a/4802483/2492962 :
<h:selectOneMenu id="comunitaValle" value="#{struttura.nomeComunitaDiValle}"
valueChangeListener="#{struttura.getComuniInComunita}" immediate="true">
<a4j:support event="onchange" reRender="cap"/>
<f:selectItems value="#{struttura.comunitaValleList}" />
</h:selectOneMenu>
<h:selectOneMenu id="cap" value="#{struttura.cap}" >
<f:selectItems value="#{struttura.comuneIstatCapList}" />
</h:selectOneMenu>