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

    h:selectOneMenu reRender problem within rich:dataTable with

      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.

        • 1. Re: h:selectOneMenu reRender problem within rich:dataTable w
          ilya_shaikovsky

          what about scope of your myBean?

          • 2. Re: h:selectOneMenu reRender problem within rich:dataTable w

            I use Seam so my bean is actually a stateful session bean that act as a controller. I didn't specify any scope so the default would be "conversation" But like I said, if you look at the 3rd column of my example, I have an EL expression that outputs the first element of the array that I want to build my combo box with, and this value gets refreshed properly (and it does have the same "rendered" clause as my combo box that is not working). This tells me that it's not a scope problem.

            I did some further testing and it seams that even if I reRender the whole table (instead of using ajaxKeys), I have the same problem. I'll try to debug some more to see if I can figure it out. Thanks for any other input you can provide.

            • 3. Re: h:selectOneMenu reRender problem within rich:dataTable w

              After further testing I'm starting to think that the bug is in Seam's "selectItems" tag. I replaced my h:selectOneMenu with a ui:repeat in which I simply output the values and the list changes properly. I also tried simply outputting the size of my array (with an EL expression that looks like this: "item.possibleValuesForSomeValue2.size()") and the count also gets refreshed properly. Maybe something is wrong with the way the EL expression is being resolved in the s:selectItems tag. I think I will try my luck in Seam's forum. I will post the results here as well in case you're interested.

              • 4. Re: h:selectOneMenu reRender problem within rich:dataTable w

                Well, it appears that upgrading from Seam v2.0.0 BETA1 to the latest daily build fixed my problem which pretty much validates my theory that the problem was really with Seam's selectItems tag. So if anyone has the same problem, make sure you use a newer version of Seam than v2.0.0 BETA1. Thanks for your help.