2 Replies Latest reply on Jun 12, 2008 8:58 AM by johnmark13

    rich:dataTable number of rows changes on Ajax request

    johnmark13

      Hi,

      Hopefully there is an easy solution to this, seems like it is quite trivial, and I'm sure I am just thinking about it in the wrong way.

      I havea datatable on my form, which takes its rows from a ManagedBean. In its simplest form:

      <rich:dataTable id="dataValues" var="value" value="#{ReferenceDataManagementBean.values}" width="100%" columnClasses="ctype, cdelete" rowClasses="oddSearchResult, evenSearchResult">
      


      I also have a few controls which can update this dataTable, via ajax requests, such as:
      <h:selectOneMenu id="dataType" styleClass="inputField" value="#{ReferenceDataManagementBean.type}">
       <f:selectItems value="#{ReferenceDataManagementBean.types}"/>
       <a4j:support disableDefault="true" ajaxSingle="true" action="#{ReferenceDataManagementBean.updateValues}" event="onchange" reRender="dataValues"/>
       </h:selectOneMenu>
      


      Some of the interactions with the data cause there to be more elements in the table than there were originally. Having read the spec I am aware that this means I can no longer interact with any new elements in the DOM, the spec suggests sticking placeholders in the page.

      So the question is, how can I have a dataTable update its contents (to possibly having more values), without having to reload the page, is it possible? If it isn't possible, can anyone suggest a better solution.

      Many Thanks for any thoughts,

      Mark.

        • 1. Re: rich:dataTable number of rows changes on Ajax request
          eicki

          In my application it works. I have a datatable and (simplified) an input field and a command button. If user hits the command button the value of the input field is added to the list of the datatable and the panel around the datatable is ajax-rererendered.
          So the only difference to your solution is that I do not directly rerender the datatable, but instead a panel.

          • 2. Re: rich:dataTable number of rows changes on Ajax request
            johnmark13

            Hi, thanks for your reply!

            I can not believe how poorly I phrased my question, sorry.

            The datatable reRenders perfectly, that isn't the problem.

            The problem is that on each row there is an a4j:commandLink. If my original table had 4 rows, and the rerendered table has 8, then the commandLinks in rows 5 - 8 will not function correctly. I am making the assumption that this is down to the fact that these have been added to the DOM, and that the viewhandler isn't properly aware of them.

            Does that make sense? and does anyone know a way to fix it without needing to reload the page.

            Thanks again,

            Mark.