How to delete data from a datatable in java and with primefaces!

0

I have a problem, as I can delete the records of a datatable at the time of clicking on a button again, so that to click on the new button the datatable is loaded:

This is the button to add a new one:

public void actionNuevo() {
        flagIU = false;
        this.assignmentVO = null;
        this.routeVo=null;
        this.vehicleVOBo = null;
        customFieldsTrip = new ArrayList<>();

    }

This is the datatable code:

<p:dataTable id="tablas_tri"  scrollable="true" scrollWidth="100%" value="#{routeAssignmentBean.customFieldsTrip}" var="fieldTrpVO"  rowIndexVar="rowIndex">                                
                                    <p:column headerText="Tripulante1">
                                        <p:outputLabel value="#{fieldTrpVO.name_employee}" />
                                    </p:column>
                                    <p:column headerText="" style="max-width: 35px">
                                        <p:commandButton icon="ui-icon-close" title="remove from cart"
                                                         accesskey="" process="@this" actionListener="#{routeAssignmentBean.deleteTripulante(fieldTrpVO)}"
                                                         update="tablas_tri" 
                                                         style="width:22px;height:22px;background-color:#FF0000;"/>
                                        <p:commandButton rendered="${beanVehicle.bottonEditarP}" class="btn-editar" value="" process="@this" title="Editar" actionListener="${routeAssignmentBean.selectCustomTripulante(fieldTrpVO)}" update="form_routes:nombreTripulante"/>               

                                    </p:column>
                                </p:dataTable>

This is the screen of what happens when I click on the button:

Previously he had clicked on the new one again and it was not deleted, there is some way that it is no longer shown, I hope and you can help me please, greetings and I am on the lookout.

    
asked by cratus666jose 04.10.2018 в 22:35
source

1 answer

0

For what you explain, if it is in the same window, then click on the button, and call a "new" event, which initializes your datatable: customFieldsTrip = new ArrayList < > (); and then you do update="dataTableId". With this the datatable should be clean.

    
answered by 08.10.2018 в 00:08