在另一个数据表中删除后,行未从数据表中删除

Row is not removed from datatable after being dropped in another datatable

我需要你的帮助,将删除的行从 datatable1 删除到 datatable2。我在 PrimeFaces 中使用拖放数据表。一旦我将行从 datatable1 拖放到 datatable2 中,该行将保留在 datatable1 中,并将添加到 datatable2 中,它应该从 datatable1 中删除。我的代码如下:

    private List<PendingRequests> listPendingRequests;

    private List<PendingRequests> droppedRequests;

    private PendingRequests selectedRequest;


    @PostConstruct

       public void init() {

           droppedRequests = new ArrayList<PendingRequests>();

           listPendingRequests= new ArrayList<PendingRequests>();

       }

public void onRequestDrop(DragDropEvent ddEvent) {

PendingRequests car = ((PendingRequests) ddEvent.getData());

droppedRequests.add(car);

listPendingRequests.remove(car);
           RequestContext.getCurrentInstance().update("Pendings:PendingRequests");

                  }     

下面是我的 xhtml:

<script type="text/javascript">

  function handleDrop(event, ui) {

  var droppedRequests = ui.draggable;

  droppedRequests.fadeOut('fast');

  }

 </script>

<h:form id="Requests">

<p:fieldset id="Pendings" legend="Pending Requests">

<p:dataTable id="PendingRequests" var="hr" value="#{hrd.pendingRequests}" >

  <p:column style="width:20px">

<h:outputText id="dragIcon" styleClass="ui-icon ui-icon-arrow-4"/>

                                <p:draggable for="dragIcon" revert="true" helper="clone"/>
 </p:column>

</p:dataTable>

</p:fieldset>

<p:fieldset id="Closed" legend="Closed Requests" style="margin-top:20px">

<p:outputPanel id="dropArea">

<h:outputText value="!!!Drop here!!!" rendered="#{empty hrd.droppedRequests}"
                            style="font-size:24px;"/>

<p:dataTable id="ClosedRequests" var="chr" value="#{hrd.droppedRequests}"                                      rendered="#{not empty hrd.droppedRequests}">

<p:column headerText="Request No.">

<h:outputText value="#{chr.reqNo}"/>

 </p:column>

 </p:dataTable>

</p:outputPanel>

</p:fieldset>

  <p:droppable for="Closed" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="PendingRequests" onDrop="handleDrop">

  <p:ajax listener="#{hrd.onRequestDrop}" update="dropArea PendingRequests"/>

 </p:droppable>

解决方案是将 arraylist 保存在 init 方法中并运行它将@postConstruct