Rich DataTable value selection issues

833 Views Asked by At

I am trying to delete data table values. my data tables shows lot of values. when i click to delete particular row in my data table then confirmation dialog box open. if click okay then call to bean and delete that values to database. if click cancel then not to call to bean.. this is my functionality..

ex: my data table show 10 rows. when i select 1 rows delete button clicked call to bean but its get another rows values pass to bean...

my UI code..

 <h:commandButton   image="/images/remove.png"  onclick="#    {rich:component('confirmation')}.show();return false"/>
<a4j:jsFunction name="submit" action="#{bean.delete}">
  <f:setPropertyActionListener target="#{bean.name}" value="#{info.name}" />
 </a4j:jsFunction>


   <rich:popupPanel id="confirmation" width="250" height="150">
   <f:facet name="header">confirmation</f:facet>
   <h:panelGrid>
   <h:panelGrid columns="2">
   <h:graphicImage value="/images/remove.png" />
  <h:outputText value="Are you sure?" style="FONT-SIZE: large;" />
  </h:panelGrid>
  <br></br> 
  <h:panelGroup >
  <center><input type="button" value="OK"
  onclick="#{rich:component('confirmation')}.hide();submit();return false"     />
 <input type="button" value="Cancel"
  onclick="#{rich:component('confirmation')}.hide();return false" />   </center>
</h:panelGroup>
</h:panelGrid>
</rich:popupPanel>
1

There are 1 best solutions below

0
On

I guess it has something to do with the 'AJAX calls out of sync'

The posted code lacks the table info so ill assume it has something to do with the AJAX handling.

<rich:extendedDataTable
    id="myTable"
    value="#{myBean.rows}"
    selectionMode="single"
    rows="#{crudBean.actionForm.occurrences}"
    ...
    rowKeyVar="idx"
    ...>
    <a4j:ajax   event="selectionchange"
      listener="#{myBean.selectionListener}"/>
    <rich:column width="30px" styleClass="#{rowItem.className}">
      <util:myInputText id="status" managedBean="#{myBean}" rowItem="#{rowItem}" rowIndex="#{idx}"/>
    </rich:column>
      <util:myDeleteRecord id="delete" managedBean="#{myBean}" rowItem="#{rowItem}" rowIndex="#{idx}"/>
    </rich:column>
</rich:extendedDataTable>

On my components i use: rowIndex="#{idx}" to make sure i know on which row i'm editing/removing