0
votes

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
What is your question?user207421
<f:setPropertyActionListener target="#{bean.name}" value="#{info.name}" /> pass wrong values to beanArjun
Is the jsFunction inside or outside of the dataTable? (I assume "info" is a variable in the table)Makhiel
Most likely 2 actions are our of sync: delete 'current' row and make selected row active. Can you post the table with at code?W vd L

1 Answers

0
votes

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