0 Replies Latest reply on Jun 17, 2008 6:15 PM by johnmark13

    rich:dataTable (again) ajax page reload commandLink

    johnmark13

      Hi,

      I didn't have much luck last time, so I will try to describe my problem more completely - it hasn't gone away!

      I have a page with a selection box, and a datatable displaying rows related to the type of data selected in the selection box. For each row there is a a4j:commandLink which does an inplace delete on the data and refreshes the datatable, there is also a h:commandLink which opens a migratedata page. On changing the value in the drop down a4j:support is used to reload the values in the backing bean and refresh the datatable - there could now be more values than there were originally.

      All of this works fine, with the proviso that I do not try to use the any of the links on rows which were not present in the originally loaded dataTable. Below is the page source:

      <ui:define name="centerPanel">
       <div class="businessErrorMessage">
       <a4j:outputPanel ajaxRendered="true">
       <h:messages showDetail="true" showSummary="false"/>
       </a4j:outputPanel>
       </div>
       <rich:panel header="#{msgs.header_manageReferenceData}">
       <h:panelGrid columns="2" columnClasses="labelColumn,">
       <h:outputText value="#{msgs.label_dataType}"/>
       <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>
       </h:panelGrid>
       <br/>
       <h:outputText styleClass="separator" value="#{msgs.separator_existingData}"/>
       <rich:separator/>
       <rich:dataTable id="dataValues" var="value" value="#{ReferenceDataManagementBean.values}" width="100%" columnClasses="ctype, cdelete" rowClasses="oddSearchResult, evenSearchResult">
       <rich:column>
       <f:facet name="header">
       <h:outputText styleClass="headerText" value="#{msgs.label_dataValue}"/>
       </f:facet>
       <h:outputText value="#{value}"/>
       </rich:column>
       <rich:column>
       <f:facet name="header">
       <h:outputText styleClass="headerText" value="#{msgs.label_delete}"/>
       </f:facet>
       <a4j:commandLink ajaxSingle="false" action="#{ReferenceDataManagementBean.deleteValue}" styleClass="deleteImage" reRender="dataValues" onclick="doBusy();" oncomplete="doComplete();">
       <h:graphicImage value="#{ReferenceDataManagementBean.deleteImage}"/>
       <f:param name="#{ConstantsBean.requestDataValue}" value="#{value}"/>
       </a4j:commandLink>
       </rich:column>
       <rich:column>
       <f:facet name="header">
       <h:outputText styleClass="headerText" value="#{msgs.label_migrate}"/>
       </f:facet>
       <h:commandLink action="#{ReferenceDataManagementBean.migrateData}" styleClass="migrateImage">
       <h:graphicImage value="#{ReferenceDataManagementBean.migrateImage}"/>
       <f:param name="#{ConstantsBean.requestDataClass}" value="#{ReferenceDataManagementBean.type}"/>
       <f:param name="#{ConstantsBean.requestDataValue}" value="#{value}"/>
       </h:commandLink>
       </rich:column>
       </rich:dataTable>
       <br/>
       <h:outputText styleClass="separator" value="#{msgs.separator_newData}"/>
       <rich:separator/>
       <h:panelGrid columns="3" columnClasses="labelColumn,,buttonColumn">
       <h:outputText value="#{msgs.label_newData}"/>
       <a4j:outputPanel ajaxRendered="true">
       <h:inputText id="newData" value="#{ReferenceDataManagementBean.newValue}" styleClass="inputField" binding="#{ReferenceDataManagementBean.newValueInput}">
       <f:validateLength minimum="4" maximum="25" />
       </h:inputText>
       </a4j:outputPanel>
       <a4j:commandButton value="#{msgs.button_add}" styleClass="commandButton" action="#{ReferenceDataManagementBean.addValue}" reRender="dataValues" onclick="doBusy();" oncomplete="doComplete();"/>
       </h:panelGrid>
       <rich:toolBar height="26">
       <rich:toolBarGroup location="right" itemSeparator="line">
       <h:commandButton value="#{msgs.button_done}" styleClass="commandButton" action="home" immediate="true"/>
       </rich:toolBarGroup>
       </rich:toolBar>
       </rich:panel>
       </ui:define>
      


      To be clear, if on page load there were 4 rows in the dataTable, and after page refresh there are 5 or more rows, all th elinks will not function on rows 5 and above.

      I do not believe I have done anything crazy, but working alone it is always possible!

      Even if no solution is known, any input will be well received. Am I right in thinking that the problem stems from the fact that on re-rendering the datatable with additional rows, the additional rows are unknown to the viewhandler?

      I can think of various solutions such as having only a single migrate buitton and a single delete button, and grabbing the selected row from a bound control, but I am not a big fan of that.

      If I am still being unclear, please prompt me for more information, Im using RichFaces 3.2.0 with facelets but I'm not sure if it is relevent to this problem, maybe...

      Thanks for reading,

      Mark.