4 Replies Latest reply on Aug 28, 2007 11:43 AM by Yannick Lazzari

    h:selectOneMenu reRender problem within rich:dataTable with

    Yannick Lazzari Newbie

      Hi,

      I have a h:selectOneMenu reRender problem within a rich:dataTable that uses ajaxKeys to control which rows are to be reRendered. Here's my template:

      <rich:dataTable value="#{myBean.someList}" var="item" ajaxKeys="#{myBean.ajaxKeys}">
       <rich:column>
       <f:facet name="header">Col 1</f:facet>
       <h:outputText value="#{item.someValue1}"/>
       </rich:column>
       <rich:column>
       <f:facet name="header">Col 2</f:facet>
       <a4j:outputPanel id="col2">
       <h:outputText value="#{item.someValue2}" rendered="#{not item.editFlag}"/>
       <h:selectOneMenu value="#{item.someValue2}" rendered="#{item.editFlag}">
       <s:selectItems value="#{item.possibleValuesForSomeValue2}" var="val label="#{val.label}"/>
       <f:converter converterId="someValue2Converter"/>
       </h:selectOneMenu>
       </a4j:outputPanel>
       </rich:column>
       <rich:column>
       <f:facet name="header">Col 3</f:facet>
       <a4j:outputPanel id="col3">
       <h:outputText value="#{item.possibleValuesForSomeValue2[0].label}" rendered="#{item.editFlag}"/>
       </a4j:outputPanel>
       </rich:column>
       <rich:column>
       <f:facet name="header">Col 4</f:facet>
       <a4j:commandButton value="Re-Render" action="#{myBean.toggleEditFlag}" reRender="col2, col3"/>
       </rich:column>
      </rich:dataTable>
      


      The idea here is that each item has a flag the tells me if the item is currently being edited or not. When an item is being edited, the 2nd column switches to a drop-down. I use the button in the 4th column to toggle the flag for the current row and the previously edited row and reRender only those 2 rows (so there's only one row being edited at a time). Each item has different possible values for property "item.someValue2", so the drop-down values should vary depending on what row is being edited.

      Now, here's my problem. Let's say I have row A and B. I click on the button for row A and its 2nd column turns into a drop-down. Then, when I click on the button for row B, the 2nd column for row A goes back to read-only and the one for row B turns into a drop-down, just like expected. The problem is that the content of the drop-down for row B is the one from row A. I need to click on the button of row B for a second time for its drop-down to be refreshed with the proper values. Does anyone have any idea why this happens?

      The 3rd column is there just for debugging purposes. It displays the first entry in the list of possible values for the property "item.someValue2" for that given row. That value gets refreshed properly everytime I click on the button. This tell me that at least I know that the list of values changes for every row.

      I'm using RichFaces 3.1.0 RC3 but I experienced the same behaviour with previous releases. Thank you for your help.