1 Reply Latest reply on Jul 3, 2009 8:37 AM by panky_p

    How to edit and update the rows in Rich faces data table

      Hi All,

      i am using Rich faces for creating data table. i want to update the rows of data table and want to save the updated values in data base.

      Here is my code for data table:

      <rich:dataTable id="basicInfolist" columns="1" value="#{clientInfo.basicInfolist}" var="basicInfo" rows="15" width="60%" sortMode="single" >
      <f:facet name="header">
      <rich:columnGroup>
      <rich:column width="50%" ><h:outputText style="text-decoration: underline" value="Basic Information" /></rich:column>
      <rich:column><h:outputText style="text-decoration: underline" value="Input" /></rich:column>
      </rich:columnGroup>
      </f:facet>
      <rich:column style="font-weight:bold;text-align: center" >
      <h:outputText value="#{basicInfo.name}" />
      </rich:column>
      <rich:column style="font-weight:bold;text-align: center" >
      <rich:inplaceInput id="basicInfoName" name="#{basicInfo.id}" value="#{basicInfo.value}"
      selectOnEdit="true" editEvent="ondblclick" showControls="true"/>
      </rich:column>

      <f:facet name="footer">
      <rich:column colspan="3">
      <rich:datascroller id="scroller" renderIfSinglePage="false"></rich:datascroller>
      </rich:column>
      </f:facet>
      </rich:dataTable>

      i am using " rich:inplaceInput " for editing the rows. after editing them i am submitting the form. In Backing bean method i want to get the changed values with their corresponding row number so that i can update them in to the data base.

      In Backing Bean i tried to get the edited rows like this:

      UIComponent comp = FacesContext.getCurrentInstance().getViewRoot().findComponent("basic:basicInfolist");
      if (comp != null) {
      UIData uIData = (UIData) comp;
      HtmlDataTable myTable = (HtmlDataTable) uIData;
      for (int i = 0; i < myTable.getRowCount(); i++) {
      myTable.setRowIndex(i);
      ClientInfoVO modifiedElement = (ClientInfoVO) myTable.getRowData();
      }
      myTable.setRowIndex(-1);
      }

      In "basic:basicInfolist" , 'basic' is the form name and 'basicInfolist' is the id of the data table.

      I am getting the comp value as null.

      can some one please help me to solve this issue. or is there any other approach for updating the rows of the data table.

      regards,
      ganesh