The empty/null value of the h:selectOneMenu during the ajax call is not set to the property in the backing bean, whereas if I select any dropdown item which has non empty / not null value, it is set to the property in the backing bean during the ajax call. I have notice this behaviour only if I use h:selectOneMenu & f:ajax inside the ui:repeat tag. And, without the ui:repeat tag , the values(both empty and non empty) are set properly to the property in the backing bean during the ajax call.
Below is the code snipet of the above mentioned scenario:
<h:panelGrid id="details">
<ui:repeat id="listId" value="#{new.List}" var="item" varStatus="itemStatus">
<h:panelGrid id="idDoc">
<ui:repeat id="docListId" value="#{item.docs}" var="docItem" varStatus="docStatus">
<h:selectOneMenu id="type" value="#{docItem.docType}" label="Type" style="" styleClass='' >
<f:selectItems value="#{new.docSelections}"/>
<f:ajax onevent="refreshDoc" event="valueChange" render="@this :form:listId:docListId:idDoc" execute=":form:listId:details" listener="#{new.save}"/>
</h:selectOneMenu>
</ui:repeat>
</h:panelGrid>
</ui:repeat>
</h:panelGrid>
Is there any problem in the way that I have used the ui:repeat,h:selectoneMenu and f:ajax?
You seem to be using Mojarra. It has indeed had several issues related to (nested)
<ui:repeat>
and component state saving. Try upgrading Mojarra to the latest version.An alternative is to just replace
<h:panelGrid><ui:repeat>
by a<h:dataTable>
as it effectively generates the same markup. The<h:dataTable>
doesn't suffer from the<ui:repeat>
issues.