1

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Nila
  • 11
  • 1
  • 3

1 Answers1

2

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.

<h:dataTable id="details" value="#{new.List}" var="item" binding="#{itemStatus}">
  <h:column>
    <h:dataTable id="idDoc" value="#{item.docs}" var="docItem" binding="#{docStatus}">
      <h:column>
        <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>
      </h:column>
    </h:dataTable>
  </h:column>
</h:dataTable>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks @BalusC . I'm currently implementing the change in my application in most of the places...will accept it if I don't find any other issues related to this. – Nila Jun 13 '12 at 06:56